home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------------------
-
- Module name: PHIGS windows.
-
- Author: Gareth Williams.
-
- Function: This module contains functions for displaying PHIGS structures
- in windows.
-
- Dependencies:
-
- Internal function list:
-
- External function list:
-
- Hashtables used: "structureid", "name", "label", "viewindex".
-
- Modification history: (Version), (Date), (name), (Description).
-
- 1.0, 5th September 1991, G. Williams, First version.
-
- 2.0, June 1992, G. Williams, Converted to ISO PHIGS C.
-
- ----------------------------------------------------------------------------*/
-
- #include <stdio.h>
- #include <math.h>
- #include <varargs.h>
- #ifdef SUN
- #include <string.h>
- #include <strings.h>
- #endif
- #ifdef PEXSI
- #include <string.h>
- #include <strings.h>
- #endif
- #include <phigs.h>
- #include "ptk.h"
-
- /* constants */
-
- #define PI 3.14159
-
- /* data types */
-
- #define ptkctmlinespace 0.008
-
- #define ptkcfloatformat 20
-
- typedef struct ptksterminal
- {
- Pint textstid;
- Pint lines, columns, curr_colm, curr_line;
- Pint visline;
- Pfloat increment;
- char floatformat[ptkcfloatformat];
- char *lastline;
- Pfloat realcols, reallines;
- Pint txfont, txcolour;
- } ptksterminal;
-
- typedef struct ptkswindow
- {
- /* window variables */
- Pint windowid;
- Pint windowstid;
- ptkewindowtype windowtype;
- ptkewindowstate windowstate;
- Pint iconstid;
- Pint wsid;
- Pint currentstid;
- Pint windowname;
- ptkboolean posted;
- Pvisual_st viewstate;
-
- Pint windowviewind;
- Ppoint windowsize;
- Ppoint windowposition;
- Ppoint iconsize;
- Ppoint iconposition;
- Ppoint framesize;
- Pint usericon;
- ptkboolean defaulticon;
- Pint backgdcolour, edgecolour, frametlcolour, framebrcolour, bannercolour;
- char titlestring[50];
- Pfloat bannerheight;
- Pint titlefont, titlecolour;
-
- Plimit3 viewlims, viewbox;
- Ppoint3 viewvolume;
- ptkecamerastate cameraswitch;
-
- /* camera variables */
- Pfloat swivelangle, twistangle, spinangle;
- Ppoint3 position; /* prp */
- Ppoint3 ptinterest; /* vrp */
- Ppoint3 positionaxis;
- Ppoint3 ptinterestaxis;
- Ppoint3 lastvpn, lastvup;
- Pproj_type cameraproj;
- Ppoint3 xaxis, yaxis;
-
- /* viewing variables */
- Ppoint3 vrp, proj_ref_point;
- Ppoint3 vpn, vup;
- Plimit win;
- Plimit3 proj_vp;
- Pproj_type proj_type;
- Pfloat viewplane, backplane, frontplane;
- Pclip_ind clipxy, clipfront, clipback;
- Plimit3 cliplimit;
-
- /* terminal window variables */
- ptksterminal term;
-
- /* topology view area */
- Plimit topviewarea;
-
- /* content window variables */
- Pint range1, range2;
- Pint viewrange1, viewrange2;
-
- /* next window */
- struct ptkswindow *next;
- } ptkswindow;
-
- typedef struct
- {
- ptkboolean postedwindows;
- ptkswindow *frontptr;
- ptkswindow *backptr;
- } ptkswswindow;
-
- /*--------------------------------------------------------------------------*/
-
- /* PHIGS viewing variables */
- static Ppoint3 vrp;
- static Ppoint3 vpn, vup;
- static Pview_map3 vmap;
-
- static ptkswindow *windptr = NULL;
- static ptkswindow *firstwind = NULL;
- static ptkswindow *lastwind = NULL;
-
- static Pint numwsids = 0;
- static Pint wsids[10];
- static ptkswswindow wswindows[10];
- static Pint windowcount = 0;
-
- static Ppoint3 origin = {0.0, 0.0, 0.0};
-
- /*--------------------------------------------------------------------------*/
-
- static void setwindow(C(Pint) windid)
- PreANSI(Pint windid)
- {
- ptkswindow *ptr;
-
- if (firstwind == NULL)
- {
- windptr = NULL;
- return;
- }
- ptr = firstwind;
- while (ptr->windowid != windid)
- {
- ptr = ptr->next;
- if (ptr == NULL)
- {
- windptr = NULL;
- return;
- }
- }
- windptr = ptr;
- } /* setwindow */
-
- /*-------------------------------------------------------------------------*/
-
- static ptkboolean getwindowid(C(Pint) windowstid, C(Pint *) windowid)
- PreANSI(Pint windowstid)
- PreANSI(Pint *windowid)
- {
- ptkswindow *ptr;
-
- ptr = firstwind;
- while (ptr->windowstid != windowstid)
- {
- ptr = ptr->next;
- if (ptr == NULL)
- return FALSE;
- }
- *windowid = ptr->windowid;
- return TRUE;
- } /* getwindowid */
-
- /*--------------------------------------------------------------------------*/
-
- static void findwsid(C(Pint) wsid, C(Pint *) ind)
- PreANSI(Pint wsid)
- PreANSI(Pint *ind)
- {
- Pint i;
-
- *ind = -1;
- for (i = 0; i < numwsids; i++)
- if (wsids[i] == wsid)
- *ind = i;
- } /* findwsid */
-
- /*--------------------------------------------------------------------------*/
-
- static void checkws(C(Pint) wsid)
- PreANSI(Pint wsid)
- {
- Pint ind;
-
- findwsid(wsid, &ind);
- if (ind == -1)
- {
- wsids[numwsids] = wsid;
- wswindows[numwsids].postedwindows = FALSE;
- wswindows[numwsids].frontptr = NULL;
- wswindows[numwsids].backptr = NULL;
- numwsids++;
- }
- } /* checkws */
-
- /*--------------------------------------------------------------------------*/
-
- static ptkboolean iswindow(C(Pint) windstid, C(ptkswindow **) wptr)
- PreANSI(Pint windstid)
- PreANSI(ptkswindow **wptr)
- {
- ptkswindow *ptr;
- ptkboolean found;
-
- ptr = firstwind;
- found = FALSE;
- while ((ptr != NULL) && (!found))
- {
- if (ptr->currentstid == windstid)
- {
- *wptr = ptr;
- found = TRUE;
- }
- else
- ptr = ptr->next;
- }
- return found;
- } /* iswindow */
-
- /*--------------------------------------------------------------------------*/
-
- static void findfront(C(Pint) wsid, C(ptkswswindow *) wsfront)
- PreANSI(Pint wsid)
- PreANSI(ptkswswindow *wsfront)
- {
- Pposted_struct_list structlist;
- Pint numstructs, error, i;
- Pfloat priority;
- ptkboolean found;
- ptkswindow *wptr;
-
- found = FALSE;
- priority = 0.0;
- i = 0;
- pinq_posted_structs(wsid, 0, 0, &error, &structlist, &numstructs);
- structlist.postings = (Pposted_struct *)calloc(numstructs,
- sizeof(Pposted_struct));
- pinq_posted_structs(wsid, numstructs, 0, &error, &structlist, &numstructs);
- for (i = 0; i < numstructs; i++)
- {
- /* find highest priority window structure */
- if (iswindow(structlist.postings[i].id, &wptr))
- if (structlist.postings[i].disp_pri > priority)
- {
- priority = structlist.postings[i].disp_pri;
- wsfront->frontptr = wptr;
- found = TRUE;
- }
- }
- if (!found)
- wsfront->postedwindows = FALSE;
- } /* findfront */
-
- /*--------------------------------------------------------------------------*/
-
- static void findback(C(Pint) wsid, C(ptkswswindow *) wsback)
- PreANSI(Pint wsid)
- PreANSI(ptkswswindow *wsback)
- {
- Pposted_struct_list structlist;
- Pint numstructs, error, i;
- Pfloat priority;
- ptkboolean found;
- ptkswindow *wptr;
-
- priority = 1.0;
- pinq_posted_structs(wsid, 0, 0, &error, &structlist, &numstructs);
- structlist.postings = (Pposted_struct *)calloc(numstructs,
- sizeof(Pposted_struct));
- pinq_posted_structs(wsid, numstructs, 0, &error, &structlist, &numstructs);
- for (i = 0; i < numstructs; i++)
- {
- /* find lowest priority window structure */
- if (iswindow(structlist.postings[i].id, &wptr))
- if (structlist.postings[i].disp_pri < priority)
- {
- priority = structlist.postings[i].disp_pri;
- wsback->backptr = wptr;
- found = TRUE;
- }
- }
- if (!found)
- wsback->postedwindows = FALSE;
- } /* findback */
-
- /*--------------------------------------------------------------------------*/
-
- static void setvalidwindowpos()
- {
- Plimit lim;
-
- lim = ptk_limit(windptr->windowposition.x - (windptr->windowsize.x / 2.0),
- windptr->windowposition.x + (windptr->windowsize.x / 2.0),
- windptr->windowposition.y - (windptr->windowsize.y / 2.0),
- windptr->windowposition.y + (windptr->windowsize.y / 2.0) +
- windptr->bannerheight);
- if ((lim.x_min < 0.0) && (lim.y_min < 0.0))
- {
- /* bottom left */
- windptr->windowposition.x += PTKMIN(1.0 - lim.x_max, -lim.x_min);
- windptr->windowposition.y += PTKMIN(1.0 - lim.y_max, -lim.y_min);
- }
- else
- if ((lim.x_min < 0.0) && (lim.y_max > 1.0))
- {
- /* top left */
- windptr->windowposition.x += PTKMIN(1.0 - lim.x_max, -lim.x_min);
- windptr->windowposition.y -= PTKMIN(lim.y_min, lim.y_max - 1.0);
- }
- else
- if ((lim.x_max > 1.0) && (lim.y_min < 0.0))
- {
- /* bottom right */
- windptr->windowposition.x -= PTKMIN(lim.x_min, lim.x_max - 1.0);
- windptr->windowposition.y += PTKMIN(1.0 - lim.y_max, -lim.y_min);
- }
- else
- if ((lim.x_max > 1.0) && (lim.y_max > 1.0))
- {
- /* top right */
- windptr->windowposition.x -= PTKMIN(lim.x_min, lim.x_max - 1.0);
- windptr->windowposition.y -= PTKMIN(lim.y_min, lim.y_max - 1.0);
- }
- else
- if (lim.x_min < 0.0)
- windptr->windowposition.x += PTKMIN(1.0 - lim.x_max, -lim.x_min);
- else
- if (lim.x_max > 1.0)
- windptr->windowposition.x -= PTKMIN(lim.x_min, lim.x_max - 1.0);
- else
- if (lim.y_min < 0.0)
- windptr->windowposition.y += PTKMIN(1.0 - lim.y_max, -lim.y_min);
- else
- if (lim.y_max > 1.0)
- windptr->windowposition.y -= PTKMIN(lim.y_min, lim.y_max - 1.0);
- } /* setvalidwindowpos */
-
- /*--------------------------------------------------------------------------*/
-
- static void setvalidwindowsize()
- {
- Plimit lim;
-
- lim = ptk_limit(windptr->windowposition.x - (windptr->windowsize.x / 2.0),
- windptr->windowposition.x + (windptr->windowsize.x / 2.0),
- windptr->windowposition.y - (windptr->windowsize.y / 2.0),
- windptr->windowposition.y + (windptr->windowsize.y / 2.0));
- if (lim.x_min < 0.0)
- lim.x_min = 0.0;
- if (lim.x_max > 1.0)
- lim.x_max = 1.0;
- if (lim.y_min < 0.0)
- lim.y_min = 0.0;
- if (lim.y_max + windptr->bannerheight > 1.0)
- lim.y_max = 1.0 - windptr->bannerheight;
- windptr->windowposition = ptk_point(lim.x_min + (lim.x_max - lim.x_min) / 2.0,
- lim.y_min + (lim.y_max - lim.y_min) / 2.0);
- windptr->windowsize = ptk_point(lim.x_max - lim.x_min, lim.y_max - lim.y_min);
- } /* setvalidwindowsize */
-
- /*--------------------------------------------------------------------------*/
-
- static void maxadjustlimits(C(Ppoint3 *) boundvolume)
- PreANSI(Ppoint3 *boundvolume)
- {
- Pfloat projht, projwt, aspectratio, maxdimen;
-
- /* calculate aspect ratio of window */
- projht = windptr->viewlims.y_max - windptr->viewlims.y_min;
- projwt = windptr->viewlims.x_max - windptr->viewlims.x_min;
- aspectratio = PTKMAX(projht, projwt) / PTKMIN(projht, projwt);
-
- /* adjust view volume to have same aspect ratio as window */
- maxdimen = PTKMAX(boundvolume->x, PTKMAX(boundvolume->y, boundvolume->z));
- windptr->viewvolume = ptk_point3(maxdimen, maxdimen, maxdimen);
-
- if (projht == projwt)
- {
- if (maxdimen > boundvolume->y)
- windptr->viewvolume.y *= aspectratio;
- if (maxdimen > boundvolume->x)
- windptr->viewvolume.x *= aspectratio;
- if (maxdimen > boundvolume->z)
- windptr->viewvolume.z *= aspectratio;
- }
- else
- if (projht > projwt)
- windptr->viewvolume.y *= aspectratio;
- else
- if (projht < projwt)
- windptr->viewvolume.x *= aspectratio;
-
- /*
- ** calculate zmax so that projection viewport has same
- ** aspect ratio as view volume.
- */
-
- windptr->viewlims.z_max = windptr->viewvolume.z *
- (projht / windptr->viewvolume.y);
- } /* maxadjustlimits */
-
- /*--------------------------------------------------------------------------*/
-
- static void adjustlimits(C(Ppoint3 *) viewvolume)
- PreANSI(Ppoint3 *viewvolume)
- {
- Pfloat projht, projwt, winwt, winht, aspectratio, winaspectratio;
- Pfloat diff, height;
-
- /* adjust view volume to have same aspect ratio as window */
-
- /* calculate aspect ratio of view area */
- if ((viewvolume->y == 0.0) || (viewvolume->x == 0.0))
- aspectratio = 1.0;
- else
- aspectratio = viewvolume->y / viewvolume->x;
-
- /* adjust projection viewport to have same aspect ratio as view volume */
- windptr->viewbox = windptr->viewlims;
- winht = windptr->viewbox.y_max - windptr->viewbox.y_min;
- winwt = windptr->viewbox.x_max - windptr->viewbox.x_min;
- if ((winht == 0.0) || (winwt == 0.0))
- winaspectratio = 1.0;
- else
- winaspectratio = winht / winwt;
- if (aspectratio > winaspectratio)
- {
- /* decrease x */
- diff = (winwt - ((1.0 / aspectratio) * winht));
- windptr->viewbox.x_max -= diff / 2.0;
- windptr->viewbox.x_min += diff / 2.0;
- }
- else
- if (aspectratio < winaspectratio)
- {
- /* decrease y */
- diff = (winht - (aspectratio * winwt));
- windptr->viewbox.y_min += diff / 2.0;
- windptr->viewbox.y_max -= diff / 2.0;
- }
-
- /*
- ** calculate zmax so that projection viewport has same
- ** aspect ratio as view volume.
- */
- height = windptr->viewbox.y_max - windptr->viewbox.y_min;
-
- if ((height == 0.0) || (viewvolume->y == 0.0))
- windptr->viewbox.z_max = 1.0;
- else
- windptr->viewbox.z_max = PTKMIN(height, viewvolume->y) /
- PTKMAX(height, viewvolume->y);
- } /* adjustlimits */
-
- /*--------------------------------------------------------------------------*/
-
- static void evalviewvolume(C(Plimit3 *) wclimits, C(ptkboolean) docube)
- PreANSI(Plimit3 *wclimits)
- PreANSI(ptkboolean docube)
- {
- Ppoint3 boundvolume, minbox, maxbox, centrebox, ptinterest, scale;
- Pmatrix3 mat;
- Ppoint3 pmin, pmax;
- Pfloat diameter;
-
- minbox = ptk_point3(wclimits->x_min, wclimits->y_min, wclimits->z_min);
- maxbox = ptk_point3(wclimits->x_max, wclimits->y_max, wclimits->z_max);
-
- /* find centre of limits */
- centrebox = ptk_subv3(&maxbox, &minbox);
- ptinterest = ptk_scalev3(¢rebox, 0.5);
- ptinterest = ptk_addv3(&ptinterest, &minbox);
- windptr->ptinterest = windptr->position = ptinterest;
- centrebox = ptk_scalev3(&ptinterest, -0.5);
- ptk_shift3(¢rebox, PTYPE_REPLACE, mat);
-
- if (docube)
- {
- /* increase box by 10 percent in all directions */
- scale = ptk_point3(1.1, 1.1, 1.1);
- ptk_scale3(&scale, PTYPE_POSTCONCAT, mat);
- }
-
- centrebox = ptk_scalev3(¢rebox, -1.0);
- ptk_shift3(¢rebox, PTYPE_POSTCONCAT, mat);
- minbox = ptk_transform3(mat, &minbox);
- maxbox = ptk_transform3(mat, &maxbox);
-
- /* bound volume is width, height and depth of limits */
- boundvolume = ptk_subv3(&maxbox, &minbox);
-
- if (docube)
- {
- diameter = sqrt((boundvolume.x * boundvolume.x) +
- (boundvolume.y * boundvolume.y) +
- (boundvolume.z * boundvolume.z));
- windptr->viewvolume = ptk_point3(diameter, diameter, diameter);
- }
- else
- windptr->viewvolume = boundvolume;
- adjustlimits(&windptr->viewvolume);
- windptr->position.z += windptr->viewvolume.z;
- } /* evalviewvolume */
-
- /*--------------------------------------------------------------------------*/
-
- static evalviewport(C(Plimit3 *) outview)
- PreANSI(Plimit3 *outview)
- {
- Pfloat unitcube;
- Ppoint origin;
-
- unitcube = PTKMIN(windptr->windowsize.x, windptr->windowsize.y);
- outview->x_min *= unitcube;
- outview->x_max *= unitcube;
- outview->y_min *= unitcube;
- outview->y_max *= unitcube;
- outview->z_min *= unitcube;
- outview->z_max *= unitcube;
- origin = windptr->windowposition;
- origin.x -= unitcube / 2.0;
- origin.y -= unitcube / 2.0;
- outview->x_min += origin.x;
- outview->x_max += origin.x;
- outview->y_min += origin.y;
- outview->y_max += origin.y;
- } /* evalviewport */
-
- /*--------------------------------------------------------------------------*/
-
- static void buildframe()
- /* build frame about the origin according to window size
- ** and frame size.
- */
- {
- Ppoint3 pts[6], centre;
- Ppoint centresize, bannercentre, bannerbox, framesize;
- Pfloat charheight;
- Ptext_align txalign;
- Ppoint_list3 sets, ptlist;
-
- centre = ptk_point3(0.0, windptr->bannerheight / 2.0, 0.0);
- centresize = windptr->windowsize;
- centresize.y += windptr->bannerheight;
- framesize = windptr->framesize;
-
- pts[0] = ptk_point3(centre.x - (centresize.x / 2.0) - framesize.x,
- centre.y - (centresize.y / 2.0) - framesize.y,
- centre.z);
- pts[1] = ptk_point3(pts[0].x, pts[0].y + centresize.y + (2.0 * framesize.y),
- centre.z);
- pts[2] = ptk_point3(pts[0].x + centresize.x + (2.0 * framesize.x), pts[1].y,
- centre.z);
- pts[3] = ptk_point3(pts[2].x - framesize.x,
- pts[2].y - framesize.y, centre.z);
- pts[4] = ptk_point3(pts[1].x + framesize.x, pts[3].y,
- centre.z);
- pts[5] = ptk_point3(pts[4].x, pts[0].y + framesize.y,
- centre.z);
- /* frame */
- pset_pick_id(PTKEWINDOWFRAME);
- pset_int_style(PSTYLE_SOLID);
- pset_int_colr_ind(windptr->frametlcolour);
- pts[2] = ptk_point3(pts[0].x + centresize.x + (2.0 * framesize.x),
- pts[1].y, centre.z);
- ptlist.num_points = 6;
- ptlist.points = pts;
- pfill_area3(&ptlist);
- pset_int_colr_ind(windptr->framebrcolour);
- pts[1].x += centresize.x + (2.0 * framesize.x);
- pts[1].y -= centresize.y + (2.0 * framesize.y);
- pts[4].x = pts[3].x;
- pts[4].y = pts[5].y;
- pfill_area3(&ptlist);
-
- /* view */
- pset_pick_id(PTKEWINDOWVIEW);
- pts[2] = ptk_point3(pts[3].x, pts[5].y, centre.z);
- pts[4] = ptk_point3(pts[0].x + framesize.x, pts[3].y,
- centre.z);
- pset_int_style(PSTYLE_SOLID);
- pset_int_colr_ind(windptr->backgdcolour);
- pset_edge_flag(PEDGE_ON);
- pset_edge_colr_ind(windptr->edgecolour);
- sets.num_points = 4;
- sets.points = &pts[2];
- ptk_fillareaset3(1, &sets);
-
- /* banner */
- pset_pick_id(PTKEWINDOWBANNER);
- pts[0] = ptk_point3(-windptr->windowsize.x / 2.0,
- windptr->windowsize.y /2.0, 0.0);
- pts[1] = ptk_point3(pts[0].x, pts[0].y + windptr->bannerheight, 0.0);
- pts[2] = ptk_point3(pts[0].x + windptr->windowsize.x, pts[1].y, 0.0);
- pts[3] = ptk_point3(pts[2].x, pts[0].y, 0.0);
- sets.num_points = 4;
- sets.points = pts;
- pset_int_colr_ind(windptr->bannercolour);
- ptk_fillareaset3(1, &sets);
- /* Implementation dependent bit - because HP doesn't support
- ** INQUIRE TEXT EXTENT, kludge to size text in window banner.
- */
- #ifdef SUN
- bannerbox = ptk_point(windptr->windowsize.x, windptr->bannerheight);
- #endif
- #ifdef HP
- bannerbox = ptk_point(windptr->windowsize.x, windptr->bannerheight * 0.7);
- #endif
- #ifdef PEXSI
- bannerbox = ptk_point(windptr->windowsize.x, windptr->bannerheight * 0.7);
- #endif
- ptk_computecharheight(windptr->wsid, windptr->titlestring, &bannerbox,
- windptr->titlefont, &charheight);
- pset_char_ht(charheight);
- txalign.hor = PHOR_CTR;
- txalign.vert = PVERT_BOTTOM;
- pset_text_align(&txalign);
- pset_text_font(windptr->titlefont);
- pset_text_colr_ind(windptr->titlecolour);
- bannercentre = ptk_point(centre.x, windptr->windowsize.y / 2.0);
- ptext(&bannercentre, windptr->titlestring);
- } /* buildframe */
-
- /*--------------------------------------------------------------------------*/
-
- static void buildicon()
- {
- Ppoint3 boxpos;
- Ppoint boxsize, framesize, iconbox, textpos;
- char str[10];
- Ptext_align align;
- Pfloat charht;
-
- boxpos = ptk_point3(0.5, 0.5, 0.0);
- boxsize = ptk_point(0.95, 0.95);
- framesize = ptk_point(0.05, 0.05);
- ptk_framebox(&boxpos, &boxsize, &framesize, windptr->backgdcolour,
- windptr->edgecolour, windptr->frametlcolour,
- windptr->framebrcolour);
- sprintf(str, "%d", windptr->windowid);
- textpos = ptk_point(0.175, 0.875);
- align.hor = PHOR_CTR;
- align.vert = PVERT_HALF;
- pset_text_align(&align);
- iconbox = ptk_point(0.15, 0.15);
- ptk_computecharheight(windptr->wsid, str, &iconbox, 1, &charht);
- pset_char_ht(charht);
- pset_text_colr_ind(1);
- ptext(&textpos, str);
- } /* buildicon */
-
- /*--------------------------------------------------------------------------*/
-
- static ptkboolean find_string(C(Pint) structure, C(char *) str)
- PreANSI(Pint structure)
- PreANSI(char *str)
- /*
- ** \parambegin
- ** \param{}{structure}{window structure id}{IN}
- ** \param{}{pickid}{item containing string}{IN}
- ** \param{}{strwindow}{string and window data}{IN}
- ** \paramend
- ** \blurb{Search for string in window items.
- ** Returns TRUE if string found, otherwise FALSE.}
- */
- {
- Pint error, eltptr, numelems;
- Psearch_status stat;
- ptkselcontent elcont;
- Pstore store;
- ptkboolean stop_search, string_found;
- Pelem_type_list include, exclude;
- Pelem_type includeelems[10], excludeelems[10];
-
- eltptr = 0;
- stop_search = FALSE;
- string_found = FALSE;
- numelems = ptk_elemcount(structure);
- do
- {
- includeelems[0] = PELEM_TEXT3;
- includeelems[1] = PELEM_TEXT;
- include.num_elem_types = 2;
- include.elem_types = includeelems;
- exclude.num_elem_types = 0;
- exclude.elem_types = excludeelems;
-
- pelem_search(structure, eltptr, PDIR_FORWARD, &include, &exclude,
- &error, &stat, &eltptr);
-
- if (error != 0)
- stop_search = TRUE;
- else
- if (stat != PSEARCH_STATUS_SUCCESS)
- stop_search = TRUE;
- else
- {
- pcreate_store(&error, &store);
- ptk_inqelemtypesizecontent(structure, eltptr, store, &error,
- &elcont);
- if (error == 0)
- {
- switch (elcont.eltype)
- {
-
- case PELEM_TEXT:
- if (strcmp(elcont.eldata->text.char_string, str) == 0)
- string_found = TRUE;
- break;
-
- case PELEM_TEXT3:
- if (strcmp(elcont.eldata->text3.char_string, str) == 0)
- string_found = TRUE;
- break;
- }
- }
- }
- eltptr++;
- ptk_delstore(store);
- } while (!string_found && !stop_search && (eltptr <= numelems));
- return string_found;
- } /* find_string */
-
- /*--------------------------------------------------------------------------*/
-
- static void updateframe()
- {
- Ppoint3 wscale;
- Pmatrix3 mat;
- Ppoint position, size;
- Ppoint3 shift;
-
- position = windptr->windowposition;
- size = windptr->windowsize;
- ptk_openstruct(windptr->windowstid);
- ptk_seteditmode(PEDIT_REPLACE);
- pset_elem_ptr(0);
- pset_elem_ptr_label(ptk_stringtoint("label", "globaltran"));
- poffset_elem_ptr(1);
- shift = ptk_point3(position.x, position.y, 0.0);
- ptk_shift3(&shift, PTYPE_REPLACE, mat);
- pset_local_tran3(mat, PTYPE_REPLACE);
- ptk_unseteditmode();
- pdel_elems_labels(ptk_stringtoint("label", "begin-frame"),
- ptk_stringtoint("label", "end-frame"));
- ptk_seteditmode(PEDIT_INSERT);
- buildframe();
- ptk_unseteditmode();
- ptk_closestruct();
- windptr->viewbox = windptr->viewlims =
- ptk_limit3(position.x - (size.x / 2.0),
- position.x + (size.x / 2.0),
- position.y - (size.y / 2.0),
- position.y + (size.y / 2.0),
- 0.0, 1.0);
- } /* updateframe */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_structicon()
- {
- /* build a spanner! */
- static Ppoint spannerpts[7] = { {-0.05, 0.0}, {-0.05, 0.2},
- {-0.1, 0.27}, {-0.1, 0.33},
- {-0.05, 0.4}, {-0.05, 0.33},
- {0.0, 0.3}};
- Ppoint pts[28], *pts2, *pts3, scale, shift;
- Ppoint_list ptlist;
- Pmatrix3 mat;
- Pint i;
-
- ptlist.num_points = 28;
- ptlist.points = pts;
- pts2 = &pts[7];
- pts3 = &pts[14];
- scale = ptk_point(-1.0, 1.0);
- ptk_scale(&scale, PTYPE_REPLACE, mat);
- for (i = 0; i < 7; i++)
- {
- pts[i] = spannerpts[i];
- pts2[i] = ptk_transform(mat, &spannerpts[6 - i]);
- }
- scale = ptk_point(1.0, -1.0);
- ptk_scale(&scale, PTYPE_REPLACE, mat);
- for (i = 0; i < 7; i++)
- {
- pts3[i] = ptk_transform(mat, &pts2[6 - i]);
- pts3[i + 7] = ptk_transform(mat, &spannerpts[6 - i]);
- }
- shift = ptk_point(0.5, 0.5);
- ptk_rotate(-45.0, PTKEZAXIS, PTYPE_REPLACE, mat);
- ptk_shift(&shift, PTYPE_POSTCONCAT, mat);
- for (i = 0; i < 28; i++)
- pts[i] = ptk_transform(mat, &pts[i]);
- ppolyline(&ptlist);
- } /* do_structicon */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_topologyicon()
- {
- /* build a simple topology */
- static Ppoint squarepts[5] = { {-0.075, -0.075}, {-0.075, 0.075},
- {0.075, 0.075}, {0.075, -0.075},
- {-0.075, -0.075}};
- Ppoint pts[5], shift;
- Ppoint_list ptlist;
- Pmatrix3 mat;
- Pint i;
-
- ptlist.num_points = 5;
- ptlist.points = pts;
-
- shift = ptk_point(0.5, 0.65);
- ptk_shift(&shift, PTYPE_REPLACE, mat);
- for (i = 0; i < 5; i++)
- pts[i] = ptk_transform(mat, &squarepts[i]);
- ppolyline(&ptlist);
-
- shift = ptk_point(0.35, 0.35);
- ptk_shift(&shift, PTYPE_REPLACE, mat);
- for (i = 0; i < 5; i++)
- pts[i] = ptk_transform(mat, &squarepts[i]);
- ppolyline(&ptlist);
-
- shift = ptk_point(0.65, 0.35);
- ptk_shift(&shift, PTYPE_REPLACE, mat);
- for (i = 0; i < 5; i++)
- pts[i] = ptk_transform(mat, &squarepts[i]);
- ppolyline(&ptlist);
-
- ptlist.num_points = 3;
- pts[0] = ptk_point(0.35, 0.425);
- pts[1] = ptk_point(0.5, 0.575);
- pts[2] = ptk_point(0.65, 0.425);
- ppolyline(&ptlist);
- } /* do_topologyicon */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_terminalicon()
- {
- /* a big T */
- static char *str = "T";
- Ppoint textpos, iconbox;
- Pfloat charht;
- Ptext_align align;
- Pint textfont;
-
- /* Implementation dependent code, choose a nice font */
- #ifdef SUN
- textfont = PFONT_COMPLEX;
- #endif
- #ifndef SUN
- /* do for HP and PEXSI */
- textfont = 1;
- #endif
- textpos = ptk_point(0.5, 0.5);
- align.hor = PHOR_CTR;
- align.vert = PVERT_HALF;
- pset_text_align(&align);
- iconbox = ptk_point(0.8, 0.8);
- /* Implementation dependent - fit "T" to icon box */
- #ifdef SUN
- ptk_computecharheight(windptr->wsid, str, &iconbox, textfont, &charht);
- pset_char_ht(charht);
- #endif
- #ifdef HP
- pset_char_ht(0.7);
- #endif
- #ifdef PEXSI
- pset_char_ht(0.7);
- #endif
- pset_text_font(textfont);
- ptext(&textpos, str);
- } /* do_terminalicon */
-
- /*--------------------------------------------------------------------------*/
-
- static void do_contenticon()
- {
- /* build a simple content */
- static Ppoint squarepts[5] = { {0.3, 0.3}, {0.3, 0.7},
- {0.7, 0.7}, {0.7, 0.3},
- {0.3, 0.3}};
- Ppoint pts[2];
- Ppoint_list ptlist;
-
- ptlist.num_points = 5;
- ptlist.points = squarepts;
- ppolyline(&ptlist);
-
- ptlist.num_points = 2;
- ptlist.points = pts;
- pts[0] = ptk_point(0.3, 0.4);
- pts[1] = ptk_point(0.7, 0.4);
- ppolyline(&ptlist);
-
- pts[0] = ptk_point(0.3, 0.5);
- pts[1] = ptk_point(0.7, 0.5);
- ppolyline(&ptlist);
-
- pts[0] = ptk_point(0.3, 0.6);
- pts[1] = ptk_point(0.7, 0.6);
- ppolyline(&ptlist);
- } /* do_contenticon */
-
- /*--------------------------------------------------------------------------*/
-
- static void updateicon()
- {
- Ppoint3 wscale, shift;
- Pmatrix3 mat;
-
- if (windptr->defaulticon)
- {
- ptk_openstruct(windptr->iconstid);
- ptk_seteditmode(PEDIT_REPLACE);
- pset_elem_ptr(0);
- pset_elem_ptr_label(ptk_stringtoint("label", "begin-icon"));
- poffset_elem_ptr(-1);
- shift = ptk_point3(-0.5, -0.5, 0.0);
- ptk_shift3(&shift, PTYPE_REPLACE, mat);
- wscale = ptk_point3(windptr->iconsize.x, windptr->iconsize.y, 1.0);
- ptk_scale3(&wscale, PTYPE_POSTCONCAT, mat);
- shift = ptk_point3(windptr->iconposition.x, windptr->iconposition.y,
- 0.0);
- ptk_shift3(&shift, PTYPE_POSTCONCAT, mat);
- pset_local_tran3(mat, PTYPE_REPLACE);
- ptk_unseteditmode();
- ptk_closestruct();
- }
- } /* updateicon */
-
- /*--------------------------------------------------------------------------*/
-
- static void updateview()
- {
- Pint err;
- Pview_rep3 vrep;
- Plimit3 cliplims;
-
- ptk_pevalvieworientationmatrix3(&windptr->vrp, &windptr->vpn,
- &windptr->vup, &err, vrep.ori_matrix);
- vmap.proj_vp = windptr->proj_vp;
- cliplims = windptr->cliplimit;
- if ((windptr->windowtype == PTKESTRUCTWINDOW) ||
- (windptr->windowtype == PTKETOPOLOGYWINDOW))
- {
- evalviewport(&vmap.proj_vp);
- evalviewport(&cliplims);
- }
- vrep.clip_limit = windptr->viewbox;
- if (windptr->clipxy == PIND_CLIP)
- {
- vrep.clip_limit.x_min = cliplims.x_min;
- vrep.clip_limit.x_max = cliplims.x_max;
- vrep.clip_limit.y_min = cliplims.y_min;
- vrep.clip_limit.y_max = cliplims.y_max;
- }
- if (windptr->clipfront == PIND_CLIP)
- vrep.clip_limit.z_min = cliplims.z_min;
- if (windptr->clipback == PIND_CLIP)
- vrep.clip_limit.z_max = cliplims.z_max;
- vrep.xy_clip = PIND_CLIP;
- vrep.back_clip = vrep.front_clip = PIND_CLIP;
- vmap.win = windptr->win;
- vmap.proj_type = windptr->proj_type;
- vmap.proj_ref_point = windptr->proj_ref_point;
- vmap.view_plane = windptr->viewplane;
- vmap.front_plane = windptr->frontplane;
- vmap.back_plane = windptr->backplane;
- peval_view_map_matrix3(&vmap, &err, vrep.map_matrix);
- if (windptr->windowstate == PTKEWINDOWOPEN)
- pset_view_rep3(windptr->wsid, windptr->windowviewind, &vrep);
- else
- windptr->viewstate = PVISUAL_ST_DEFER;
- } /* updateview */
-
- /*--------------------------------------------------------------------------*/
-
- static void updatecamera()
- {
- Pint err;
- Pview_rep3 vrep;
- Pmatrix3 twistmat;
- Ppoint3 origin, initvpn, inittwist;
-
- vrp = windptr->ptinterest;
- vpn = ptk_subv3(&windptr->position, &vrp);
- vpn = ptk_unitv3(&vpn);
- ptk_rotatevv3(&windptr->lastvpn, &vpn, PTYPE_REPLACE, twistmat, &err);
- vup = ptk_transform3(twistmat, &windptr->lastvup);
- vup = ptk_unitv3(&vup);
- windptr->lastvup = vup;
- origin = ptk_point3(0.0, 0.0, 0.0);
- ptk_rotateline3(&origin, &vpn, windptr->twistangle, PTYPE_POSTCONCAT,
- twistmat, &err);
- vup = ptk_transform3(twistmat, &vup);
- ptk_pevalvieworientationmatrix3(&vrp, &vpn, &vup, &err, vrep.ori_matrix);
- windptr->lastvpn = vpn;
- vrep.clip_limit = windptr->viewlims;
- vrep.xy_clip = PIND_CLIP;
- vrep.back_clip = vrep.front_clip = PIND_CLIP;
- vmap.win = ptk_limit(-windptr->viewvolume.x / 2.0,
- windptr->viewvolume.x / 2.0,
- -windptr->viewvolume.y / 2.0,
- windptr->viewvolume.y / 2.0);
- vmap.proj_vp = windptr->viewbox;
- vmap.proj_type = windptr->cameraproj;
- vmap.proj_ref_point = ptk_point3(0.0, 0.0, windptr->viewvolume.z);
- vmap.front_plane = windptr->viewvolume.z / 2.0;
- vmap.view_plane = 0.0;
- vmap.back_plane = -windptr->viewvolume.z / 2.0;
-
- peval_view_map_matrix3(&vmap, &err, vrep.map_matrix);
-
- if (windptr->windowstate == PTKEWINDOWOPEN)
- pset_view_rep3(windptr->wsid, windptr->windowviewind, &vrep);
- else
- windptr->viewstate = PVISUAL_ST_DEFER;
- } /* updatecamera */
-
- /*--------------------------------------------------------------------------*/
-
- static void updatewindowview()
- {
- if (windptr->cameraswitch == PTKECAMERAON)
- updatecamera();
- else
- updateview();
- } /* updatewindowview */
-
- /*--------------------------------------------------------------------------*/
-
- static void initialiseterminal()
- {
- Pfloat oneline;
-
- /* view mapping */
- windptr->proj_type = PTYPE_PARAL;
- windptr->proj_ref_point = ptk_point3(windptr->windowsize.x / 2.0,
- windptr->windowsize.y / 2.0, 1.0);
- windptr->win = ptk_limit(0.0, windptr->windowsize.x, 0.0,
- windptr->windowsize.y);
- windptr->proj_vp = windptr->cliplimit = windptr->viewlims;
- windptr->backplane = windptr->viewplane = 0.0;
- windptr->frontplane = 1.0;
- /* view orientation */
- oneline = -windptr->windowsize.y/(Pfloat)windptr->term.lines;
- windptr->vrp = ptk_point3(0.0, -windptr->windowsize.y +
- (oneline * (Pfloat)(windptr->term.visline - 1)), 0.0);
- windptr->vpn = ptk_point3(0.0, 0.0, 1.0);
- windptr->vup = ptk_point3(0.0, 1.0, 0.0);
- /* set view rep */
- updateview();
- } /* initialiseterminal */
-
- /*--------------------------------------------------------------------------*/
- /*------------------------ Camera functions --------------------------------*/
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_rotatecameraposition(C(Pint) windid, C(Pfloat) angle)
- PreANSI(Pint windid)
- PreANSI(Pfloat angle)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pfloat}{angle}{rotation angle in degrees}{IN}
- ** \paramend
- ** \blurb{This function rotates the camera position in a circle centred
- ** at the point of interest and about the axis defined by the function
- ** {\tt ptk\_setpositionaxis}. The amount of rotation is {\tt angle}
- ** degrees and the function is useful for rotating around an object.}
- */
- {
- Pmatrix3 spinmat, mat;
- Ppoint3 origin;
- Ppoint3 shiftprp;
- Pint err;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- /* shift by -(vrp), rotate about arbitrary axis, shift by (vrp) */
- shiftprp = ptk_scalev3(&windptr->ptinterest, -1.0);
- ptk_shift3(&shiftprp, PTYPE_REPLACE, spinmat);
- origin = ptk_point3(0.0, 0.0, 0.0);
- ptk_rotateline3(&origin, &windptr->positionaxis,
- angle, PTYPE_POSTCONCAT, spinmat, &err);
- ptk_shift3(&windptr->ptinterest, PTYPE_POSTCONCAT, spinmat);
- windptr->position = ptk_transform3(spinmat, &windptr->position);
- /* transform fixed x and y axes */
- ptk_rotateline3(&origin, &windptr->positionaxis, angle,
- PTYPE_REPLACE, mat, &err);
- windptr->xaxis = ptk_transform3(mat, &windptr->xaxis);
- windptr->yaxis = ptk_transform3(mat, &windptr->yaxis);
- updatecamera();
- }
- } /* ptk_rotatecameraposition */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setpositionaxis(C(Pint) windid, C(Ppoint3 *) axis)
- PreANSI(Pint windid)
- PreANSI(Ppoint3 *axis)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint3 *}{axis}{axis of rotation}{IN}
- ** \paramend
- ** \blurb{This function sets the axis of rotation for rotating
- ** the camera position using the function {\tt ptk\_rotatecameraposition}.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- windptr->positionaxis = *axis;
- } /* ptk_setpositionaxis */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setptinterestaxis(C(Pint) windid, C(Ppoint3 *) axis)
- PreANSI(Pint windid)
- PreANSI(Ppoint3 *axis)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint3 *}{axis}{axis of rotation}{IN}
- ** \paramend
- ** \blurb{This function sets the axis of rotation for rotating
- ** the camera point of interest using the function
- ** {\tt ptk\_rotatecameraptinterest}.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- windptr->ptinterestaxis = *axis;
- } /* ptk_setptinterestaxis */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_scaleviewwindow(C(Pint) windid, C(Pfloat) scalefactor)
- PreANSI(Pint windid)
- PreANSI(Pfloat scalefactor)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pfloat}{scalefactor}{scale factor}{IN}
- ** \paramend
- ** \blurb{This function scales the view window uniformly
- ** by {\tt scalefactor}. A scalefactor in the range [0, 1] will
- ** scale down the view window and create a zoom-in effect.
- ** A scalefactor greater than 1.0 will give a zoom-out effect.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- if (scalefactor != 0.0)
- {
- windptr->viewvolume.x *= scalefactor;
- windptr->viewvolume.y *= scalefactor;
- updatecamera();
- }
- }
- } /* ptk_scaleviewwindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_rotatecameraptinterest(C(Pint) windid, C(Pfloat) angle)
- PreANSI(Pint windid)
- PreANSI(Pfloat angle)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pfloat}{angle}{rotation angle in degrees}{IN}
- ** \paramend
- ** \blurb{This function rotates the camera point of interest in a circle
- ** centred at the camera position and about the axis defined by the function
- ** {\tt ptk\_setptinterestaxis}. The amount of rotation is {\tt angle}
- ** degrees and the function is useful for panning around a scene.}
- */
- {
- Pmatrix3 spinmat, mat;
- Ppoint3 origin;
- Ppoint3 shiftprp;
- Pint err;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- /* shift by -(prp), rotate about arbitrary axis, shift by (prp) */
- shiftprp = ptk_scalev3(&windptr->position, -1.0);
- ptk_shift3(&shiftprp, PTYPE_REPLACE, spinmat);
- origin = ptk_point3(0.0, 0.0, 0.0);
- ptk_rotateline3(&origin, &windptr->ptinterestaxis,
- angle, PTYPE_POSTCONCAT, spinmat, &err);
- ptk_shift3(&windptr->position, PTYPE_POSTCONCAT, spinmat);
- windptr->ptinterest = ptk_transform3(spinmat, &windptr->ptinterest);
- /* transform fixed x and y axes */
- ptk_rotateline3(&origin, &windptr->ptinterestaxis, angle,
- PTYPE_REPLACE, mat, &err);
- windptr->xaxis = ptk_transform3(mat, &windptr->xaxis);
- windptr->yaxis = ptk_transform3(mat, &windptr->yaxis);
- updatecamera();
- }
- } /* ptk_rotatecameraptinterest */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_rotatecameraupvector(C(Pint) windid, C(Pfloat) angle)
- PreANSI(Pint windid)
- PreANSI(Pfloat angle)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pfloat}{angle}{rotation angle in degrees}{IN}
- ** \paramend
- ** \blurb{This function rotates the camera up vector
- ** about the axis joining the camera position to the point of interest by
- ** {\tt angle} degrees.}
- */
- {
- Pmatrix3 mat;
- Pint err;
- Ppoint3 zaxis;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- /* rotate about z axis */
- windptr->twistangle += angle;
- zaxis = ptk_crossv3(&windptr->xaxis, &windptr->yaxis);
- ptk_rotateline3(&origin, &zaxis, angle, PTYPE_REPLACE, mat, &err);
- windptr->xaxis = ptk_transform3(mat, &windptr->xaxis);
- windptr->yaxis = ptk_transform3(mat, &windptr->yaxis);
- updatecamera();
- }
- } /* ptk_rotatecameraupvector */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_rotatepositionyaxis(C(Pint) windid, C(Pfloat) angle)
- PreANSI(Pint windid)
- PreANSI(Pfloat angle)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pfloat}{angle}{rotation angle in degrees}{IN}
- ** \paramend
- ** \blurb{This function rotates the camera position in a circle centred
- ** at the point of interest and about the y axis of a right-handed
- ** coordinate system whose z axis is defined by the camera position and
- ** point of interest.}
- */
- {
- Pmatrix3 mat;
- Pint err;
- Ppoint3 tempaxis;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- ptk_inqpositionaxis(windid, &tempaxis, &err);
- ptk_setpositionaxis(windid, &windptr->yaxis);
- ptk_rotatecameraposition(windid, -angle);
- ptk_setpositionaxis(windid, &tempaxis);
- }
- } /* ptk_rotatepositionyaxis */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_rotatepositionxaxis(C(Pint) windid, C(Pfloat) angle)
- PreANSI(Pint windid)
- PreANSI(Pfloat angle)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pfloat}{angle}{rotation angle in degrees}{IN}
- ** \paramend
- ** \blurb{This function rotates the camera position in a circle centred
- ** at the point of interest and about the x axis of a right-handed
- ** coordinate system whose z axis is defined by the camera position and
- ** point of interest.}
- */
- {
- Pmatrix3 mat;
- Pint err;
- Ppoint3 tempaxis;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- ptk_inqpositionaxis(windid, &tempaxis, &err);
- ptk_setpositionaxis(windid, &windptr->xaxis);
- ptk_rotatecameraposition(windid, -angle);
- ptk_setpositionaxis(windid, &tempaxis);
- }
- } /* ptk_rotatepositionxaxis */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_rotateptinterestyaxis(C(Pint) windid, C(Pfloat) angle)
- PreANSI(Pint windid)
- PreANSI(Pfloat angle)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pfloat}{angle}{rotation angle in degrees}{IN}
- ** \paramend
- ** \blurb{This function rotates the camera point of interest
- ** in a circle centred
- ** at the camera position and about the y axis of a right-handed
- ** coordinate system whose z axis is defined by the camera position and
- ** point of interest.}
- */
- {
- Pmatrix3 mat;
- Pint err;
- Ppoint3 tempaxis;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- ptk_inqptinterestaxis(windid, &tempaxis, &err);
- ptk_setptinterestaxis(windid, &windptr->yaxis);
- ptk_rotatecameraptinterest(windid, -angle);
- ptk_setptinterestaxis(windid, &tempaxis);
- }
- } /* ptk_rotateptinterestyaxis */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_rotateptinterestxaxis(C(Pint) windid, C(Pfloat) angle)
- PreANSI(Pint windid)
- PreANSI(Pfloat angle)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pfloat}{angle}{rotation angle in degrees}{IN}
- ** \paramend
- ** \blurb{This function rotates the camera point of interest
- ** in a circle centred
- ** at the camera position and about the x axis of a right-handed
- ** coordinate system whose z axis is defined by the camera position and
- ** point of interest.}
- */
- {
- Pmatrix3 mat;
- Pint err;
- Ppoint3 tempaxis;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- ptk_inqptinterestaxis(windid, &tempaxis, &err);
- ptk_setptinterestaxis(windid, &windptr->xaxis);
- ptk_rotatecameraptinterest(windid, -angle);
- ptk_setptinterestaxis(windid, &tempaxis);
- }
- } /* ptk_rotateptinterestxaxis */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_shiftcamera(C(Pint) windid, C(Ppoint3 *) shift)
- PreANSI(Pint windid)
- PreANSI(Ppoint3 *shift)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint3 *}{shift}{shift factor}{IN}
- ** \paramend
- ** \blurb{This function shifts the camera point of interest
- ** and camera position about the axes of a right-handed
- ** coordinate system whose z axis is defined by the camera position
- ** and point of interest.}
- */
- {
- Pmatrix3 mat;
- Pint err;
- Ppoint3 newshift;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- ptk_0to3pt(&origin, &windptr->xaxis, &windptr->yaxis, PTYPE_REPLACE,
- mat);
- newshift = ptk_transform3(mat, shift);
- ptk_shift3(&newshift, PTYPE_REPLACE, mat);
- windptr->position = ptk_transform3(mat, &windptr->position);
- windptr->ptinterest = ptk_transform3(mat, &windptr->ptinterest);
- updatecamera();
- }
- } /* ptk_shiftcamera */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setcameraposition(C(Pint) windid, C(Ppoint3 *) position)
- PreANSI(Pint windid)
- PreANSI(Ppoint3 *position)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint3 *}{position}{camera position}{IN}
- ** \paramend
- ** \blurb{This function sets the camera position to {\tt position}
- ** which is given in World Coordinates.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- windptr->position = *position;
- /* reset last vectors to defaults */
- windptr->lastvpn = ptk_point3(0.0, 0.0, 1.0);
- windptr->lastvup = ptk_point3(0.0, 1.0, 0.0);
- windptr->twistangle = 0.0;
- updatecamera();
- }
- } /* ptk_setcameraposition */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setcameraptinterest(C(Pint) windid, C(Ppoint3 *) ptinterest)
- PreANSI(Pint windid)
- PreANSI(Ppoint3 *ptinterest)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint3 *}{ptinterest}{point of interest}{IN}
- ** \paramend
- ** \blurb{This function sets the camera point of interest to
- ** {\tt ptinterest} which is given in World Corrdinates.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- windptr->ptinterest = *ptinterest;
- updatecamera();
- }
- } /* ptk_setcameraptinterest */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setcameraprojtype(C(Pint) windid, C(Pproj_type) proj)
- PreANSI(Pint windid)
- PreANSI(Pproj_type proj)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pproj\_type}{proj}{camera projection type}{IN}
- ** \paramend
- ** \blurb{This function sets the projection type of the view given by the
- ** camera to PARALLEL or PERSPECTIVE. The default is PARALLEL.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- windptr->cameraproj = proj;
- updatecamera();
- }
- } /* ptk_setcameraprojtype */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setcamerastate(C(Pint) windid,
- C(ptkecamerastate) cameraswitch)
- PreANSI(Pint windid)
- PreANSI(ptkecamerastate cameraswitch)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{ptkecamerastate}{cameraswitch}{camera on or off}{IN}
- ** \paramend
- ** \blurb{This function sets the camera of the window {\tt windid}
- ** to ON or OFF. The default is ON.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- windptr->cameraswitch = cameraswitch;
- updatewindowview();
- }
- } /* ptk_setcamerastate */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setcameraworld(C(Pint) windid, C(Pint_list *) stids)
- PreANSI(Pint windid)
- PreANSI(Pint_list *stids)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint\_list *}{stids}{structure identifier list}{IN}
- ** \paramend
- ** \blurb{This function initialises the view volume of the camera so
- ** that it contains the combined bounding box of all the
- ** structures and structure networks in {\tt stids}. The camera position
- ** and point of interest are set accordingly.}
- */
- {
- Pint i;
- Plimit3 cameraworld, stlimits;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- cameraworld = ptk_limit3(10000.0, -10000.0, 10000.0, -10000.0, 10000.0,
- -10000.0);
- for (i = 0; i < stids->num_ints; i++)
- {
- if (ptk_boundingbox(stids->ints[i], &stlimits, TRUE))
- {
- if (stlimits.x_min < cameraworld.x_min)
- cameraworld.x_min = stlimits.x_min;
- if (stlimits.y_min < cameraworld.y_min)
- cameraworld.y_min = stlimits.y_min;
- if (stlimits.z_min < cameraworld.z_min)
- cameraworld.z_min = stlimits.z_min;
- if (stlimits.x_max > cameraworld.x_max)
- cameraworld.x_max = stlimits.x_max;
- if (stlimits.y_max > cameraworld.y_max)
- cameraworld.y_max = stlimits.y_max;
- if (stlimits.z_max > cameraworld.z_max)
- cameraworld.z_max = stlimits.z_max;
- }
- }
- evalviewvolume(&cameraworld, TRUE);
- updatecamera();
- }
- } /* ptk_setcameraworld */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setcameralimits(C(Pint) windid, C(Plimit3 *) limits,
- C(ptkboolean) adjust)
- PreANSI(Pint windid)
- PreANSI(Plimit3 *limits)
- PreANSI(ptkboolean adjust)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Plimit3 *}{limits}{camera viewing limits in WC}{IN}
- ** \param{ptkboolean}{adjust}{adjust given limits}{IN}
- ** \paramend
- ** \blurb{This function initialises the view volume of the camera
- ** to the specified bounding box given in World Coordinates. If
- ** {\tt adjust} is set to TRUE then the bounding box will be adjusted
- ** to be the bounding box of a sphere which encloses the original box.
- ** The camera position and point of interest are set accordingly.}
- */
- {
- Pint i;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- evalviewvolume(limits, adjust);
- updatecamera();
- }
- } /* ptk_setcameralimits */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_resetcamera(C(Pint) windid)
- PreANSI(Pint windid)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \paramend
- ** \blurb{This function resets the camera variables to their default
- ** values. The camera view volume is left unchanged.}
- */
- {
- Pint i;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- windptr->position = ptk_point3(0.5, 0.5, 2.0);
- windptr->ptinterest = ptk_point3(0.5, 0.5, 0.5);
- windptr->positionaxis = ptk_point3(0.0, 1.0, 0.0);
- windptr->ptinterestaxis = ptk_point3(0.0, 1.0, 0.0);
- windptr->lastvpn = ptk_point3(0.0, 0.0, 1.0);
- windptr->lastvup = ptk_point3(0.0, 1.0, 0.0);
- windptr->xaxis = ptk_point3(1.0, 0.0, 0.0);
- windptr->yaxis = ptk_point3(0.0, 1.0, 0.0);
- windptr->swivelangle = windptr->spinangle =
- windptr->twistangle = 0.0;
- windptr->cameraproj = PTYPE_PARAL;
- if (windptr->cameraswitch == PTKECAMERAON)
- updatecamera();
- }
- } /* ptk_resetcamera */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqcameraposition(C(Pint) windid, C(Ppoint3 *) position,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Ppoint3 *position)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint3 *}{position}{camera position}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the camera position in
- ** World Coordinates.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *position = windptr->position;
- else
- *err = 1;
- } /* ptk_inqcameraposition */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqcameraptinterest(C(Pint) windid, C(Ppoint3 *) ptinterest,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Ppoint3 *ptinterest)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint3 *}{ptinterest}{camera point of interest}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the camera point of interest
- ** in World Coordinates.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *ptinterest = windptr->ptinterest;
- else
- *err = 1;
- } /* ptk_inqcameraptinterest */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqcameraprojtype(C(Pint) windid, C(Pproj_type *) projtype,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pproj_type *projtype)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pproj\_type *}{projtype}{camera projection type}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the camera view projection
- ** type which is either PARALLEL or PERSPECTIVE.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *projtype = windptr->proj_type;
- else
- *err = 1;
- } /* ptk_inqcameraprojtype */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqcamerastate(C(Pint) windid,
- C(ptkecamerastate *) cameraswitch, C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(ptkecamerastate *cameraswitch)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{ptkecamerastate *}{cameraswitch}{camera ON/OFF switch}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the camera state which is
- ** either ON or OFF.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *cameraswitch = windptr->cameraswitch;
- else
- *err = 1;
- } /* ptk_inqcamerastate */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqcameralimits(C(Pint) windid, C(Plimit3 *) limits,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Plimit3 *limits)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Plimit3 *}{limits}{camera world limits}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the camera view volume.
- ** This defines the volume of a scene that the camera knows about
- ** and is returned in World Coordinates.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- {
- *limits = ptk_limit3(windptr->ptinterest.x - windptr->viewvolume.x / 2.0,
- windptr->ptinterest.x + windptr->viewvolume.x / 2.0,
- windptr->ptinterest.y - windptr->viewvolume.y / 2.0,
- windptr->ptinterest.y + windptr->viewvolume.y / 2.0,
- windptr->ptinterest.z - windptr->viewvolume.z / 2.0,
- windptr->ptinterest.z + windptr->viewvolume.z / 2.0);
- }
- else
- *err = 1;
- } /* ptk_inqcameralimits */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqpositionaxis(C(Pint) windid, C(Ppoint3 *) axis,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Ppoint3 *axis)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint3 *}{axis}{camera position axis of rotation}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the axis of rotation
- ** which is used to rotate the camera position in the function
- ** {\tt ptk\_rotatecameraposition}.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *axis = windptr->positionaxis;
- else
- *err = 1;
- } /* ptk_inqpositionaxis */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqptinterestaxis(C(Pint) windid, C(Ppoint3 *) axis,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Ppoint3 *axis)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint3 *}{axis}{camera point of interest axis of rotation}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the axis of rotation
- ** which is used to rotate the camera point of interest in the function
- ** {\tt ptk\_rotatecameraptinterest}.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *axis = windptr->ptinterestaxis;
- else
- *err = 1;
- } /* ptk_inqptinterestaxis */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqwindowviewrep(C(Pint) windid, C(Pview_rep3 *) rep,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pview_rep3 *rep)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pview\_rep3 *}{rep}{window view representation}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the viewing parameters
- ** which are used to set the window view when the camera is switched
- ** OFF.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- Pview_map3 vmap;
-
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- {
- ptk_pevalvieworientationmatrix3(&windptr->vrp, &windptr->vpn,
- &windptr->vup, err, rep->ori_matrix);
- vmap.proj_vp = windptr->proj_vp;
- vmap.win = windptr->win;
- vmap.proj_type = windptr->proj_type;
- vmap.proj_ref_point = windptr->proj_ref_point;
- vmap.view_plane = windptr->viewplane;
- vmap.front_plane = windptr->frontplane;
- vmap.back_plane = windptr->backplane;
- peval_view_map_matrix3(&vmap, err, rep->map_matrix);
- rep->clip_limit = windptr->cliplimit;
- rep->xy_clip = windptr->clipxy;
- rep->back_clip = windptr->clipback;
- rep->front_clip = windptr->clipfront;
- }
- else
- *err = 1;
- } /* ptk_inqwindowviewrep */
-
- /*--------------------------------------------------------------------------*/
- /*------------------------ Viewing functions -------------------------------*/
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setvieworientation3(C(Pint) windid, C(Ppoint3 *) vrp,
- C(Ppoint3 *) vpn, C(Ppoint3 *) vup, C(Pint *) error)
- PreANSI(Pint windid)
- PreANSI(Ppoint3 *vrp)
- PreANSI(Ppoint3 *vpn)
- PreANSI(Ppoint3 *vup)
- PreANSI(Pint *error)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint3 *}{vrp}{view reference point}{IN}
- ** \param{Ppoint3 *}{vpn}{view plane normal}{IN}
- ** \param{Ppoint3 *}{vup}{view up vector}{IN}
- ** \param{Pint *}{error}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function sets the window view orientation values.
- ** The camera must be switched OFF for these values to be set.
- ** The error code is a standard PHIGS error code.}
- */
- {
- Pmatrix3 orimat;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- ptk_pevalvieworientationmatrix3(vrp, vpn, vup, error, orimat);
- if (*error == 0)
- {
- windptr->vrp = *vrp;
- windptr->vpn = *vpn;
- windptr->vup = *vup;
- updateview();
- }
- }
- } /* ptk_setvieworientation3 */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setviewmapping3(C(Pint) windid, C(Plimit *) window,
- C(Plimit3 *) viewport, C(Pproj_type) proj, C(Ppoint3 *) prp,
- C(Pfloat) viewplane, C(Pfloat) backplane, C(Pfloat) frontplane,
- C(Pint *) error)
- PreANSI(Pint windid)
- PreANSI(Plimit *window)
- PreANSI(Plimit3 *viewport)
- PreANSI(Pproj_type proj)
- PreANSI(Ppoint3 *prp)
- PreANSI(Pfloat viewplane)
- PreANSI(Pfloat backplane)
- PreANSI(Pfloat frontplane)
- PreANSI(Pint *error)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Plimit *}{window}{view window}{IN}
- ** \param{Plimit3 *}{viewport}{projection viewport}{IN}
- ** \param{Pproj\_type}{proj}{projection type}{IN}
- ** \param{Ppoint3 *}{prp}{projection reference point}{IN}
- ** \param{Pfloat}{viewplane}{view plane distance}{IN}
- ** \param{Pfloat}{backplane}{back plane distance}{IN}
- ** \param{Pfloat}{frontplane}{front plane distance}{IN}
- ** \param{Pint *}{error}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function sets the window view mapping values.
- ** The camera must be switched OFF for these values to be set.
- ** The largest square within the window is defined to be the
- ** device coordinates area which the view maps onto.
- ** The error code is a standard PHIGS error code.}
- */
- {
- Pmatrix3 mapmat;
- Pview_map3 mapping;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- mapping.win = *window;
- mapping.proj_type = proj;
- mapping.proj_ref_point = *prp;
- mapping.view_plane = viewplane;
- mapping.back_plane = backplane;
- mapping.front_plane = frontplane;
- mapping.proj_vp = *viewport;
- evalviewport(&mapping.proj_vp);
- peval_view_map_matrix3(&mapping, error, mapmat);
- if (*error == 0)
- {
- windptr->win = *window;
- windptr->proj_vp = *viewport;
- windptr->proj_type = proj;
- windptr->proj_ref_point = *prp;
- windptr->viewplane = viewplane;
- windptr->backplane = backplane;
- windptr->frontplane = frontplane;
- updateview();
- }
- }
- } /* ptk_setviewmapping3 */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setviewclipping3(C(Pint) windid, C(Plimit3 *) cliplims,
- C(Pclip_ind) clipxy, C(Pclip_ind) clipback, C(Pclip_ind) clipfront)
- PreANSI(Pint windid)
- PreANSI(Plimit3 *cliplims)
- PreANSI(Pclip_ind clipxy)
- PreANSI(Pclip_ind clipfront)
- PreANSI(Pclip_ind clipback)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Plimit3 *}{cliplims}{view clipping limits}{IN}
- ** \param{Pclip\_ind}{clipxy}{x-y clipping indicator}{IN}
- ** \param{Pclip\_ind}{clipback}{back plane clipping indicator}{IN}
- ** \param{Pclip\_ind}{clipfront}{front plane clipping indicator}{IN}
- ** \paramend
- ** \blurb{This function sets the window view clipping values.
- ** The camera must be switched OFF for these values to be set.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- windptr->cliplimit = *cliplims;
- windptr->clipxy = clipxy;
- windptr->clipback = clipback;
- windptr->clipfront = clipfront;
- updateview();
- }
- } /* ptk_setviewclipping3 */
-
- /*--------------------------------------------------------------------------*/
- /*------------------- Window system functions ------------------------------*/
- /*--------------------------------------------------------------------------*/
-
- static void createwindow(C(Pint) wsid, C(Pint) windid, C(Ppoint *) size,
- C(Ppoint *) position, C(Pint) backgdcolour,
- C(Pint) edgecolour, C(Pint) frametlcolour, C(Pint) framebrcolour,
- C(Pint) titlecolour, C(char *) titlestring)
- PreANSI(Pint wsid)
- PreANSI(Pint windid)
- PreANSI(Ppoint *size)
- PreANSI(Ppoint *position)
- PreANSI(Pint backgdcolour)
- PreANSI(Pint edgecolour)
- PreANSI(Pint frametlcolour)
- PreANSI(Pint framebrcolour)
- PreANSI(Pint titlecolour)
- PreANSI(char *titlestring)
- /*
- ** \parambegin
- ** \param{Pint}{wsid}{workstation identifier}{IN}
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{size}{window size}{IN}
- ** \param{Ppoint *}{position}{window position}{IN}
- ** \param{Pint}{backgdcolour}{background colour index of window}{IN}
- ** \param{Pint}{edgecolour}{edge colour index of window}{IN}
- ** \param{Pint}{frametlcolour}{top-left frame colour index}{IN}
- ** \param{Pint}{framebrcolour}{bottom-right frame colour index}{IN}
- ** \param{Pint}{titlecolour}{title string colour index}{IN}
- ** \param{char *}{titlestring}{title string}{IN}
- ** \paramend
- ** \blurb{This function creates a window structure which may be used
- ** for viewing PHIGS structures, PHIGS Toolkit topology diagrams and
- ** PHIGS Toolkit structure content diagrams. A terminal window
- ** type which contains only text. The window size and position are
- ** given in the range [0, 1]. Each window has a virtual camera
- ** which is useful for moving around a scene.}
- */
- {
- Pint err, inclname;
- Pview_rep3 vrep;
- char stname[30], str[10];
- Ppoint textpos, iconbox, boxsize, framesize;
- Pmatrix3 unitmat, mat;
- Ppoint3 wscale, shift, boxpos;
- Pfloat charht;
- Ptext_align align;
- Pint_list incl;
-
- setwindow(windid);
- if (windptr == NULL)
- {
- if (lastwind == NULL)
- {
- firstwind = lastwind = windptr =
- (ptkswindow *)malloc(sizeof(ptkswindow));
- windptr->next = NULL;
- }
- else
- {
- lastwind->next = windptr = (ptkswindow *)malloc(sizeof(ptkswindow));
- windptr->next = NULL;
- lastwind = lastwind->next;
- }
-
- windowcount++;
- windptr->wsid = wsid;
- checkws(wsid);
- windptr->windowid = windid;
- sprintf(stname, "ptk$window%d", windid);
- windptr->windowstid = windptr->currentstid =
- ptk_stringtoint("structureid", stname);
- sprintf(stname, "ptk$icon%d", windid);
- windptr->iconstid = ptk_stringtoint("structureid", stname);
- sprintf(stname, "view$window%d", windid);
- windptr->windowviewind = ptk_stringtoint("viewindex", stname);
- sprintf(stname, "name$window%d", windid);
- windptr->windowname = ptk_stringtoint("name", stname);
- windptr->windowsize = *size;
- windptr->windowposition = *position;
-
- /* default camera variables */
- windptr->position = ptk_point3(0.5, 0.5, 2.0);
- windptr->ptinterest = ptk_point3(0.5, 0.5, 0.5);
- windptr->positionaxis = ptk_point3(0.0, 1.0, 0.0);
- windptr->ptinterestaxis = ptk_point3(0.0, 1.0, 0.0);
- windptr->lastvpn = ptk_point3(0.0, 0.0, 1.0);
- windptr->lastvup = ptk_point3(0.0, 1.0, 0.0);
- windptr->swivelangle = windptr->spinangle =
- windptr->twistangle = 0.0;
- windptr->cameraproj = PTYPE_PARAL;
- windptr->xaxis = ptk_point3(1.0, 0.0, 0.0);
- windptr->yaxis = ptk_point3(0.0, 1.0, 0.0);
-
- /* default viewing variables */
- windptr->proj_type = PTYPE_PARAL;
- windptr->vrp = ptk_point3(0.5, 0.5, 0.5);
- windptr->proj_ref_point = ptk_point3(0.0, 0.0, 2.0);
- windptr->vpn = ptk_point3(0.0, 0.0, 1.0);
- windptr->vup = ptk_point3(0.0, 1.0, 0.0);
- windptr->win = ptk_limit(-0.5, 0.5, -0.5, 0.5);
- windptr->proj_vp = ptk_limit3(0.0, 1.0, 0.0, 1.0, 0.0, 1.0);
- windptr->frontplane = 0.5;
- windptr->viewplane = 0.0;
- windptr->backplane = -0.5;
- windptr->clipxy = windptr->clipfront = windptr->clipback = PIND_NO_CLIP;
-
- /* other window defaults */
- windptr->windowtype = PTKESTRUCTWINDOW;
- windptr->cameraswitch = PTKECAMERAON;
- windptr->framesize = ptk_point(0.01, 0.01);
- windptr->iconsize = ptk_point(0.1, 0.1);
- windptr->iconposition = windptr->windowposition;
- windptr->defaulticon = TRUE;
- windptr->titlefont = 1;
- windptr->bannerheight = 0.02;
- windptr->bannercolour = backgdcolour;
-
- windptr->backgdcolour = backgdcolour;
- windptr->edgecolour = edgecolour;
- windptr->frametlcolour = frametlcolour;
- windptr->framebrcolour = framebrcolour;
- windptr->titlecolour = titlecolour;
- strncpy(windptr->titlestring, titlestring, strlen(titlestring) + 1);
- windptr->posted = FALSE;
- windptr->windowstate = PTKEWINDOWOPEN;
- windptr->viewstate = PVISUAL_ST_CORRECT;
-
- windptr->viewbox = windptr->viewlims = windptr->cliplimit =
- ptk_limit3(position->x - (size->x / 2.0),
- position->x + (size->x / 2.0),
- position->y - (size->y / 2.0),
- position->y + (size->y / 2.0),
- 0.0, 1.0);
- windptr->viewvolume = ptk_point3(1.0, 1.0, 1.0);
-
- /* make window structure */
- ptk_seteditmode(PEDIT_INSERT);
- ptk_openstruct(windptr->windowstid);
-
- incl.num_ints = 1;
- incl.ints = &inclname;
- incl.ints[0] = windptr->windowname;
- padd_names_set(&incl);
-
- plabel(ptk_stringtoint("label", "globaltran"));
- /* window frame transformation */
- shift = ptk_point3(windptr->windowposition.x, windptr->windowposition.y,
- 0.0);
- ptk_shift3(&shift, PTYPE_REPLACE, mat);
- pset_local_tran3(mat, PTYPE_REPLACE);
-
- plabel(ptk_stringtoint("label", "begin-frame"));
- buildframe();
- plabel(ptk_stringtoint("label", "end-frame"));
-
- pset_int_style(PSTYLE_HOLLOW);
- pset_edge_flag(PEDGE_OFF);
- pset_edge_colr_ind(1);
- pset_int_colr_ind(1);
- pset_text_colr_ind(1);
- pset_char_ht(0.01);
- pset_text_font(1);
- align.hor = PHOR_NORM;
- align.vert = PVERT_NORM;
- pset_text_align(&align);
-
- ptk_unitmatrix3(mat);
- pset_local_tran3(mat, PTYPE_REPLACE);
- pset_view_ind(windptr->windowviewind);
-
- plabel(ptk_stringtoint("label", "begin-window"));
-
- plabel(ptk_stringtoint("label", "end-window"));
- premove_names_set(&incl);
- ptk_closestruct();
-
- updatecamera();
-
- /* make default window icon structure */
- ptk_openstruct(windptr->iconstid);
- padd_names_set(&incl);
- pset_pick_id(PTKEWINDOWICON);
- shift = ptk_point3(-0.5, -0.5, 0.0);
- ptk_shift3(&shift, PTYPE_REPLACE, mat);
- wscale.x = windptr->iconsize.x;
- wscale.y = windptr->iconsize.y;
- wscale.z = 1.0;
- ptk_scale3(&wscale, PTYPE_POSTCONCAT, mat);
- shift = ptk_point3(windptr->iconposition.x, windptr->iconposition.y,
- 0.0);
- ptk_shift3(&shift, PTYPE_POSTCONCAT, mat);
- pset_local_tran3(mat, PTYPE_REPLACE);
-
- plabel(ptk_stringtoint("label", "begin-icon"));
- buildicon();
- plabel(ptk_stringtoint("label", "begin-icon-pic"));
- do_structicon();
- plabel(ptk_stringtoint("label", "end-icon"));
-
- premove_names_set(&incl);
- ptk_closestruct();
- ptk_unseteditmode();
- }
- } /* createwindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_createwindow(C(Pint) wsid, C(Pint) windid, C(Ppoint *) size,
- C(Ppoint *) position, C(char *) titlestring)
- PreANSI(Pint wsid)
- PreANSI(Pint windid)
- PreANSI(Ppoint *size)
- PreANSI(Ppoint *position)
- PreANSI(char *titlestring)
- /*
- ** \parambegin
- ** \param{Pint}{wsid}{workstation identifier}{IN}
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{size}{window size}{IN}
- ** \param{Ppoint *}{position}{window position}{IN}
- ** \param{char *}{titlestring}{title string}{IN}
- ** \paramend
- ** \blurb{This function creates a window structure which may be used
- ** for viewing PHIGS structures, PHIGS Toolkit topology diagrams and
- ** PHIGS Toolkit structure content diagrams. A terminal window
- ** type which contains only text. The window size and position are
- ** given in the range [0, 1]. Each window has a virtual camera
- ** which is useful for moving around a scene.
- ** This function requires hashtables "structureid", "label", "name",
- ** "viewindex".}
- */
- {
- createwindow(wsid, windid, size, position, 0, 1, 1, 1, 1, titlestring);
- } /* ptk_createwindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setwindowattrs(C(Pint) windid,
- C(Pint) titlefont, C(Pint) titlecolour, C(Pint) bannercolour,
- C(Pint) backgdcolour, C(Pint) edgecolour,
- C(Pint) frametlcolour, C(Pint) framebrcolour)
- PreANSI(Pint windid)
- PreANSI(Pint titlefont)
- PreANSI(Pint titlecolour)
- PreANSI(Pint bannercolour)
- PreANSI(Pint backgdcolour)
- PreANSI(Pint edgecolour)
- PreANSI(Pint frametlcolour)
- PreANSI(Pint framebrcolour)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint}{titlefont}{title string font}{IN}
- ** \param{Pint}{titlecolour}{title string colour index}{IN}
- ** \param{Pint}{bannercolour}{banner colour index}{IN}
- ** \param{Pint}{backgdcolour}{background colour index of window}{IN}
- ** \param{Pint}{edgecolour}{edge colour index of window}{IN}
- ** \param{Pint}{frametlcolour}{top-left frame colour index}{IN}
- ** \param{Pint}{framebrcolour}{bottom-right frame colour index}{IN}
- ** \paramend
- ** \blurb{This function sets the window text font and colour attribute
- ** values. Each window has a banner region which contains the title
- ** string of the window. The text font value applies to this string.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- /* other window defaults */
- windptr->titlefont = titlefont;
- windptr->titlecolour = titlecolour;
- windptr->bannercolour = bannercolour;
- windptr->backgdcolour = backgdcolour;
- windptr->edgecolour = edgecolour;
- windptr->frametlcolour = frametlcolour;
- windptr->framebrcolour = framebrcolour;
-
- ptk_seteditmode(PEDIT_INSERT);
- ptk_openstruct(windptr->windowstid);
- pset_elem_ptr(0);
- /* set window frame attributes */
- pdel_elems_labels(ptk_stringtoint("label", "begin-frame"),
- ptk_stringtoint("label", "end-frame"));
- buildframe();
- ptk_closestruct();
-
- ptk_openstruct(windptr->iconstid);
- pset_elem_ptr(0);
- /* set icon frame attributes */
- pdel_elems_labels(ptk_stringtoint("label", "begin-icon"),
- ptk_stringtoint("label", "begin-icon-pic"));
- buildicon();
- ptk_closestruct();
- ptk_unseteditmode();
- }
- } /* ptk_setwindowattrs */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_posttowindow(C(Pint) windid, C(Pint) id)
- PreANSI(Pint windid)
- PreANSI(Pint id)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint}{id}{item identifier}{IN}
- ** \paramend
- ** \blurb{This function posts an item to a window depending on the
- ** window type. In the case
- ** of STRUCT and CONTENT windows, {\tt id} is a structure identifier.
- ** For TOPOLOGY windows, {\tt id} is a topology identifier. If the window is
- ** a TERMINAL window this function is ignored.}
- */
- {
- Pint stid, err, elptr, lstnum, fid;
- Pelem_type eltype;
- Psearch_status stat;
- ptkboolean found;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype != PTKETERMINALWINDOW)
- {
- if (windptr->windowtype == PTKETOPOLOGYWINDOW)
- ptk_inqtopologystructid(id, &stid, &err);
- else
- stid = id;
- /* add to window structure */
- ptk_openstruct(windptr->windowstid);
- ptk_seteditmode(PEDIT_INSERT);
- pset_elem_ptr(0);
- pset_elem_ptr_label(ptk_stringtoint("label", "begin-window"));
-
- /* check if execute is already there */
- eltype = PELEM_EXEC_STRUCT;
- found = FALSE;
- do
- {
- ptk_findelemtype(&eltype, 1, PDIR_FORWARD, &stat, &elptr, &lstnum);
- if (stat == PSEARCH_STATUS_SUCCESS)
- {
- ptk_getexecuteid(windptr->windowstid, elptr, &fid);
- if (fid == stid)
- found = TRUE;
- pset_elem_ptr(elptr + 1);
- }
- } while ((!found) && (stat == PSEARCH_STATUS_SUCCESS));
- if (!found)
- {
- pset_elem_ptr(0);
- pset_elem_ptr_label(ptk_stringtoint("label", "begin-window"));
- pexec_struct(stid);
- }
- ptk_unseteditmode();
- ptk_closestruct();
- if (windptr->windowtype == PTKECONTENTWINDOW)
- {
- ptk_inqstructcontentrange(stid, &windptr->range1, &windptr->range2,
- &err);
- windptr->viewrange1 = 0;
- windptr->viewrange2 = windptr->range2;
- }
- }
- }
- } /* ptk_posttowindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_frontwindow(C(Pint) windid)
- PreANSI(Pint windid)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \paramend
- ** \blurb{This function sets the post priority of the window structure
- ** so that it is displayed on top of all other posted windows but
- ** has a lower prioity than the current back menu.}
- */
- {
- Pint ind, err, frontmenu, backmenu, backmenustid;
- ptkboolean menus;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- findwsid(windptr->wsid, &ind);
- menus = ptk_inqfrontbackmenuid(windptr->wsid, &frontmenu, &backmenu,
- &err);
- if (menus)
- {
- ptk_inqmenustructid(backmenu, &backmenustid, &err);
- ptk_postrelative(windptr->wsid, windptr->currentstid, PPRI_LOWER,
- backmenustid, &err);
- }
- else
- if (!wswindows[ind].postedwindows)
- ppost_struct(windptr->wsid, windptr->windowstid, 0.0);
- else
- ptk_postrelative(windptr->wsid, windptr->currentstid, PPRI_HIGHER,
- wswindows[ind].frontptr->currentstid, &err);
- if (!wswindows[ind].postedwindows)
- {
- wswindows[ind].frontptr = wswindows[ind].backptr = windptr;
- wswindows[ind].postedwindows = TRUE;
- }
- else
- {
- wswindows[ind].frontptr = windptr;
- if (windptr->currentstid == wswindows[ind].backptr->currentstid)
- findback(windptr->wsid, &wswindows[ind]);
- }
- windptr->posted = TRUE;
- }
- } /* ptk_frontwindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_backwindow(C(Pint) windid)
- PreANSI(Pint windid)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \paramend
- ** \blurb{This function sets the post priority of a window structure
- ** so that it is displayed behind all the other posted windows and menus.}
- */
- {
- Pint ind, err, frontmenu, backmenu, backmenustid;
- ptkboolean menus;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- findwsid(windptr->wsid, &ind);
- menus = ptk_inqfrontbackmenuid(windptr->wsid, &frontmenu, &backmenu,
- &err);
- if (!wswindows[ind].postedwindows)
- {
- if (menus)
- {
- ptk_inqmenustructid(backmenu, &backmenustid, &err);
- ptk_postrelative(windptr->wsid, windptr->currentstid, PPRI_LOWER,
- backmenustid, &err);
- }
- else
- ppost_struct(windptr->wsid, windptr->currentstid, 0.0);
- wswindows[ind].frontptr = wswindows[ind].backptr = windptr;
- wswindows[ind].postedwindows = TRUE;
- }
- else
- {
- ptk_postrelative(windptr->wsid, windptr->currentstid, PPRI_LOWER,
- wswindows[ind].backptr->currentstid, &err);
- wswindows[ind].backptr = windptr;
- if (windptr == wswindows[ind].frontptr)
- findfront(windptr->wsid, &wswindows[ind]);
- }
- windptr->posted = TRUE;
- }
- } /* ptk_backwindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_unpostfromwindow(C(Pint) windid, C(Pint) id)
- PreANSI(Pint windid)
- PreANSI(Pint id)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint}{id}{item identifier}{IN}
- ** \paramend
- ** \blurb{This function unposts an item from a window depending on the
- ** window type. In the case
- ** of STRUCT and CONTENT windows, id is a structure identifier.
- ** For TOPOLOGY windows, id is a topology identifier. If the window is
- ** a TERMINAL window this function is ignored.}
- */
- {
- Pint stid, elptr, lstnum, err, fid;
- Pelem_type eltype;
- Psearch_status stat;
- ptkboolean found;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype != PTKETERMINALWINDOW)
- {
- if (windptr->windowtype == PTKETOPOLOGYWINDOW)
- ptk_inqtopologystructid(id, &stid, &err);
- else
- stid = id;
- /* add to window structure */
- ptk_openstruct(windptr->windowstid);
- ptk_seteditmode(PEDIT_INSERT);
- pset_elem_ptr(0);
- pset_elem_ptr_label(ptk_stringtoint("label", "begin-window"));
-
- /* check if execute is already there */
- eltype = PELEM_EXEC_STRUCT;
- found = FALSE;
- do
- {
- ptk_findelemtype(&eltype, 1, PDIR_FORWARD, &stat, &elptr, &lstnum);
- if (stat == PSEARCH_STATUS_SUCCESS)
- {
- ptk_getexecuteid(windptr->windowstid, elptr, &fid);
- if (fid == stid)
- found = TRUE;
- pset_elem_ptr(elptr + 1);
- }
- } while ((!found) && (stat == PSEARCH_STATUS_SUCCESS));
- if (found)
- {
- pset_elem_ptr(elptr);
- pdel_elem();
- }
- ptk_unseteditmode();
- ptk_closestruct();
- }
- }
- } /* ptk_unpostfromwindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_unpostallfromwindow(C(Pint) windid)
- PreANSI(Pint windid)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \paramend
- ** \blurb{This function unposts all items posted to window {\tt windid}.
- ** If the window is a TERMINAL window this function is ignored.}
- */
- {
- Pint label1, label2;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype != PTKETERMINALWINDOW)
- {
- ptk_openstruct(windptr->windowstid);
- /* Implementation dependent code
- ** because of problem with delelemslabels in SunPHIGS
- */
- #ifdef SUN
- pset_elem_ptr(0);
- ptk_findlabel(ptk_stringtoint("label", "begin-window"), &label1);
- pset_elem_ptr(0);
- ptk_findlabel(ptk_stringtoint("label", "end-window"), &label2);
- if ((label2 - label1) > 1)
- {
- if ((label2 - label1) == 2)
- {
- pset_elem_ptr(0);
- pset_elem_ptr(label1);
- poffset_elem_ptr(1);
- pdel_elem();
- }
- else
- pdel_elem_range(label1 + 1, label2 - 1);
- }
- #endif
- #ifndef SUN
- /* do for HP and PEXSI */
- pset_elem_ptr(0);
- pdel_elems_labels(ptk_stringtoint("label", "begin-window"),
- ptk_stringtoint("label", "end-window"));
- #endif
- ptk_closestruct();
- }
- }
- } /* ptk_unpostallfromwindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_postwindow(C(Pint) windid)
- PreANSI(Pint windid)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \paramend
- ** \blurb{This function posts a window structure to the workstation
- ** specified when the window was initially created. Windows are bound
- ** to workstation because they each use one view table entry to
- ** define the window view. The priority of the window structure is
- ** controlled by the PHIGS Toolkit window system to provide an ordered
- ** stacking mechanism for windows.}
- */
- {
- ptk_frontwindow(windid);
- } /* ptk_postwindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_unpostwindow(C(Pint) windid)
- PreANSI(Pint windid)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \paramend
- ** \blurb{This function unposts a window from the workstation it is
- ** bound to.}
- */
- {
- Pint ind;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- punpost_struct(windptr->wsid, windptr->currentstid);
- findwsid(windptr->wsid, &ind);
- if (windptr == wswindows[ind].backptr)
- findback(windptr->wsid, &wswindows[ind]);
- if (windptr == wswindows[ind].frontptr)
- findfront(windptr->wsid, &wswindows[ind]);
- windptr->posted = FALSE;
- }
- } /* ptk_unpostwindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern ptkboolean ptk_delwindow(C(Pint) windid)
- PreANSI(Pint windid)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \paramend
- ** \blurb{This function deletes a window from the PHIGS Toolkit window
- ** store.}
- */
- {
- ptkswindow *ptr, *junk;
- char stname[20];
-
- ptk_unpostwindow(windid);
- ptr = firstwind;
- if (ptr->windowid == windid)
- {
- firstwind = firstwind->next;
- if (lastwind->windowid == windid)
- lastwind = firstwind;
- pdel_struct(ptr->windowstid);
- pdel_struct(ptr->iconstid);
- if (ptr->windowtype == PTKETERMINALWINDOW)
- {
- pdel_struct(ptr->term.textstid);
- sprintf(stname, "ptk$term%d", windid);
- ptk_delstring("structureid", stname);
- }
- free(ptr);
- }
- else
- {
- while (ptr->next->windowid != windid)
- {
- ptr = ptr->next;
- if (ptr->next == NULL)
- return FALSE;
- }
- junk = ptr->next;
- ptr->next = junk->next;
- pdel_struct(junk->windowstid);
- pdel_struct(junk->iconstid);
- if (ptr->windowtype == PTKETERMINALWINDOW)
- {
- pdel_struct(junk->term.textstid);
- sprintf(stname, "ptk$term%d", windid);
- ptk_delstring("structureid", stname);
- }
- free(junk);
- if (ptr->next == NULL)
- lastwind = ptr;
- }
-
- /* delete strings */
- sprintf(stname, "ptk$window%d", windid);
- ptk_delstring("structureid", stname);
- sprintf(stname, "ptk$icon%d", windid);
- ptk_delstring("structureid", stname);
- sprintf(stname, "view$window%d", windid);
- ptk_delstring("viewindex", stname);
- sprintf(stname, "name$window%d", windid);
- ptk_delstring("name", stname);
- windowcount--;
- return TRUE;
- } /* ptk_delwindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_openwindow(C(Pint) windid)
- PreANSI(Pint windid)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \paramend
- ** \blurb{This function posts the window structure and unposts the icon
- ** structure from the window's workstation.}
- */
- {
- Pfloat priority;
- Pint err;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowstate == PTKEWINDOWCLOSED)
- {
- ptk_inqpostpriority(windptr->wsid, windptr->iconstid, &priority, &err);
- punpost_struct(windptr->wsid, windptr->iconstid);
- ppost_struct(windptr->wsid, windptr->windowstid, priority);
- windptr->windowstate = PTKEWINDOWOPEN;
- windptr->currentstid = windptr->windowstid;
- if (windptr->viewstate == PVISUAL_ST_DEFER)
- {
- updatewindowview();
- windptr->viewstate = PVISUAL_ST_CORRECT;
- }
- }
- }
- } /* ptk_openwindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_closewindow(C(Pint) windid)
- PreANSI(Pint windid)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \paramend
- ** \blurb{This function posts the icon structure and unposts the window
- ** structure from the window's workstation.}
- */
- {
- Pfloat priority;
- Pint err;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowstate == PTKEWINDOWOPEN)
- {
- ptk_inqpostpriority(windptr->wsid, windptr->windowstid, &priority,
- &err);
- punpost_struct(windptr->wsid, windptr->windowstid);
- ppost_struct(windptr->wsid, windptr->iconstid, priority);
- windptr->windowstate = PTKEWINDOWCLOSED;
- windptr->currentstid = windptr->iconstid;
- }
- }
- } /* ptk_closewindow */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setwindowposition(C(Pint) windid, C(Ppoint *) position)
- PreANSI(Pint windid)
- PreANSI(Ppoint *position)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{position}{window position}{IN}
- ** \paramend
- ** \blurb{This function sets the position of the centre of the window.
- ** The position is given in the range [0, 1]. If the position results
- ** in part of the window being clipped then the position is adjusted
- ** so that the whole window is visible.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- windptr->windowposition = *position;
- setvalidwindowpos();
- updateframe();
- if (windptr->windowtype == PTKESTRUCTWINDOW)
- adjustlimits(&windptr->viewvolume);
- if (windptr->windowtype == PTKETERMINALWINDOW)
- windptr->proj_vp = windptr->cliplimit = windptr->viewlims;
- if (windptr->windowtype == PTKECONTENTWINDOW)
- ptk_setcontentviewrange(windid, windptr->viewrange1,
- windptr->viewrange2);
- else
- updatewindowview();
- }
- } /* ptk_setwindowposition */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setwindowsize(C(Pint) windid, C(Ppoint *) size)
- PreANSI(Pint windid)
- PreANSI(Ppoint *size)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{size}{window size}{IN}
- ** \paramend
- ** \blurb{This function sets the size of the window using the x value
- ** as the width and the y value as the height. The values are given
- ** in the range [0, 1]. If the size results in part of the window
- ** being clipped then the window size is adjusted to give as large a
- ** window as possible.}
- */
- {
- Pfloat height, extraspace, textspace, oldlinesize;
- Pfloat newlinesize, newlines;
- Ppoint oldsize;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- oldsize = windptr->windowsize;
- windptr->windowsize = *size;
- setvalidwindowsize();
- switch (windptr->windowtype)
- {
- case PTKESTRUCTWINDOW:
- updateframe();
- adjustlimits(&windptr->viewvolume);
- updatewindowview();
- break;
-
- case PTKETERMINALWINDOW:
- windptr->term.realcols *= (windptr->windowsize.x / oldsize.x);
- windptr->term.columns = windptr->term.curr_colm =
- (Pint)windptr->term.realcols;
- height = windptr->windowsize.y / oldsize.y;
- oldlinesize = oldsize.y/(Pfloat)windptr->term.lines;
- windptr->term.reallines *= height;
- newlines = (Pfloat)floor(windptr->term.reallines);
- extraspace = windptr->windowsize.y - (oldsize.y *
- (newlines / (Pfloat)windptr->term.lines));
- windptr->term.lines = (Pint)windptr->term.reallines;
- windptr->term.increment += extraspace/newlines;
- newlinesize = size->y/(Pfloat)windptr->term.lines;
- textspace = (Pfloat)windptr->term.curr_line * oldlinesize;
- windptr->term.curr_line = (Pint)((Pfloat)textspace / newlinesize) + 1;
- updateframe();
- initialiseterminal();
- break;
-
- case PTKECONTENTWINDOW:
- updateframe();
- ptk_setcontentviewrange(windid, windptr->viewrange1,
- windptr->viewrange2);
- break;
-
- case PTKETOPOLOGYWINDOW:
- updateframe();
- ptk_settopologyviewarea(windid, &windptr->topviewarea);
- break;
- }
- }
- } /* ptk_setwindowsize */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setwindowtraninputpri(C(Pint) windid, C(Pint) refwindid,
- C(Prel_pri) priority)
- PreANSI(Pint windid)
- PreANSI(Pint refwindid)
- PreANSI(Prel_pri priority)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint}{refwindid}{reference window identifier}{IN}
- ** \param{Prel\_pri}{priority}{relative priority}{IN}
- ** \paramend
- ** \blurb{This function sets the transformation input priority of the
- ** window's view representation relative to another window.
- ** The relative priority is also set relative to view index 0.}
- */
- {
- Pint refindex;
- ptkswindow *ptrwindow;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- if (iswindow(refwindid, &ptrwindow))
- {
- refindex = ptrwindow->windowviewind;
- pset_view_tran_in_pri(windptr->wsid, windptr->windowviewind, refindex,
- priority);
- }
- pset_view_tran_in_pri(windptr->wsid, windptr->windowviewind, 0,
- priority);
- }
- } /* ptk_setwindowtraninputpri */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setframesize(C(Pint) windid, C(Ppoint *) size)
- PreANSI(Pint windid)
- PreANSI(Ppoint *size)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{size}{frame size}{IN}
- ** \paramend
- ** \blurb{This function sets the thickness of the window frame. The
- ** x and y dimensions are given in the range [0, 1].}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- if ((size->x > 0.0) && (size->y > 0.0))
- {
- windptr->framesize = *size;
- updateframe();
- }
- }
- } /* ptk_setframesize */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern ptkboolean ptk_stringscanwindows(C(Pint) wsid, C(char *) str,
- C(Pint *) windowid)
- PreANSI(Pint wsid)
- PreANSI(char *str)
- PreANSI(Pint *windowid)
- /*
- ** \parambegin
- ** \param{Pint}{wsid}{workstation identifier}{IN}
- ** \param{char *}{str}{string}{IN}
- ** \param{Pint *}{windowid}{window identifier}{OUT}
- ** \paramend
- ** \blurb{This function compares the character string {\tt str} with
- ** title string of all the windows posted to workstation {\tt wsid}.
- ** The string comparison is case sensitive and begins with the
- ** front window and works back to the lowest priority window.
- ** The function returns TRUE if a match is found, otherwise FALSE.}
- */
- {
- ptkboolean windowfound;
- Pint_list *windows;
- ptkswindow *ptrwindow;
- Pint numstructs, i, err;
- Pposted_struct_list structlist;
- Pfilter *invisfilt;
- Pstore store;
-
- windowfound = FALSE;
- structlist.postings = NULL;
- pinq_posted_structs(wsid, 0, 0, &err, &structlist, &numstructs);
- structlist.postings = (Pposted_struct *)calloc(numstructs,
- sizeof(Pposted_struct));
- pinq_posted_structs(wsid, numstructs, 0, &err, &structlist, &numstructs);
-
- /* inquire invisibility filter */
- pcreate_store(&err, &store);
- pinq_invis_filter(wsid, store, &err, &invisfilt);
-
- /* This bit is a bit dodgy because it relies on structlist being ordered
- ** by PHIGS into highest priority last. This is not standard PHIGS,
- ** so if version is not sorted do a sort.
- */
- i = numstructs - 1;
- while ((i >= 0) && (!windowfound))
- {
- if (iswindow(structlist.postings[i].id, &ptrwindow))
- {
- /* check invisibility filter */
- if (!((inintlst(ptrwindow->windowname, &invisfilt->incl_set) != -1) &&
- (inintlst(ptrwindow->windowname, &invisfilt->excl_set) == -1)))
- {
- if (find_string(ptrwindow->currentstid, str))
- {
- windowfound = TRUE;
- *windowid = ptrwindow->windowid;
- }
- }
- }
- i--;
- }
- ptk_delstore(store);
- free(structlist.postings);
- return windowfound;
- } /* ptk_stringscanwindows */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern ptkboolean ptk_pickscanwindows(C(Ppick_path *) pickpath,
- C(Ppath_order) pathorder, C(Pint *) windowid, C(ptkewindowarea *) windowarea)
- PreANSI(Ppick_path *pickpath)
- PreANSI(Ppath_order pathorder)
- PreANSI(Pint *windowid)
- PreANSI(ptkewindowarea *windowarea)
- /*
- ** \parambegin
- ** \param{Ppick\_path *}{pickpath}{path through structure network}{IN}
- ** \param{Ppath\_order}{pathorder}{order of path through network}{IN}
- ** \param{Pint *}{windowid}{window identifier}{OUT}
- ** \paramend
- ** \blurb{This function tests the pick path to inquire if a window
- ** structure was picked. The window area picked may be one of
- ** BANNER, VIEW, FRAME or ICON. The function
- ** returns TRUE if a window was picked, otherwise FALSE.}
- */
- {
- Pint windowstid;
-
- if (pathorder == PORDER_TOP_FIRST)
- {
- *windowarea = pickpath->path_list[pickpath->depth - 1].pick_id;
- windowstid = pickpath->path_list[0].struct_id;
- return (getwindowid(windowstid, windowid));
- }
- else
- {
- *windowarea = pickpath->path_list[0].pick_id;
- windowstid = pickpath->path_list[pickpath->depth - 1].struct_id;
- return (getwindowid(windowstid, windowid));
- }
- } /* ptk_pickscanwindows */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern ptkboolean ptk_locscanwindows(C(Pint) wsid, C(Ppoint *) point,
- C(Pint *) windowid, C(ptkewindowarea *) windowarea, C(Ppoint *) value)
- PreANSI(Pint wsid)
- PreANSI(Ppoint *point)
- PreANSI(Pint *windowid)
- PreANSI(ptkewindowarea *windowarea)
- PreANSI(Ppoint *value)
- /*
- ** \parambegin
- ** \param{Pint}{wsid}{workstation identifier}{IN}
- ** \param{Ppoint *}{point}{input point}{IN}
- ** \param{Pint *}{windowid}{window identifier}{OUT}
- ** \param{ptkewindowarea *}{windowarea}{window area}{OUT}
- ** \param{Ppoint *}{value}{position of point within window area}{OUT}
- ** \paramend
- ** \blurb{This function uses the INCREMENTAL SPATIAL SEARCH function
- ** of PHIGS to test if {\tt point} lies within a window
- ** posted to workstation {\tt wsid}. The window area (one of
- ** BANNER, VIEW, FRAME or ICON) and the position of {\tt point} relative
- ** to the bottom-left corner of the bounding box of the window area are
- ** returned in {\tt windowarea} and {\tt value}.
- ** The function returns TRUE if {\tt point} lies within a window,
- ** otherwise FALSE.}
- */
- {
- ptkboolean windowfound;
- ptkswindow *ptrwindow;
- Plimit3 windowbox, area;
- Pint numstructs, i, err;
- Pposted_struct_list structlist;
- Pint lstnum, stopelem;
- Pelem_type eltype;
- Psearch_status stat;
- Pfloat div;
- Pfilter *invisfilt;
- Pstore store;
-
- ptk_stacktsl();
- ptk_stackbbox();
- eltype = PELEM_VIEW_IND;
- windowfound = FALSE;
- structlist.postings = NULL;
- pinq_posted_structs(wsid, 0, 0, &err, &structlist, &numstructs);
- structlist.postings = (Pposted_struct *)calloc(numstructs,
- sizeof(Pposted_struct));
- pinq_posted_structs(wsid, numstructs, 0, &err, &structlist, &numstructs);
-
- /* inquire invisibility filter */
- pcreate_store(&err, &store);
- pinq_invis_filter(wsid, store, &err, &invisfilt);
-
- /* This bit is a bit dodgy because it relies on structlist being ordered
- ** by PHIGS into highest priority last. This is not standard PHIGS,
- ** so if version is not sorted do a sort.
- ** HP orders with highest priority first.
- */
- #ifndef HP
- /* do for SUN and PEXSI */
- i = numstructs - 1;
- while ((i >= 0) && (!windowfound))
- #endif
- #ifdef HP
- i = 0;
- while ((i < numstructs) && (!windowfound))
- #endif
- {
- if (iswindow(structlist.postings[i].id, &ptrwindow))
- {
- /* check invisibility filter */
- if (!((inintlst(ptrwindow->windowname, &invisfilt->incl_set) != -1) &&
- (inintlst(ptrwindow->windowname, &invisfilt->excl_set) == -1)))
- {
- if (ptrwindow->windowstate == PTKEWINDOWOPEN)
- {
- ptk_openstruct(ptrwindow->currentstid);
- pset_elem_ptr(0);
- ptk_findelemtype(&eltype, 1, PDIR_FORWARD, &stat, &stopelem, &lstnum);
- ptk_closestruct();
- ptk_inittsl();
- ptk_tsltraverserange(ptrwindow->currentstid, 1,
- ptrwindow->currentstid, stopelem, TRUE);
- ptk_inqboundingbox(&windowbox);
- }
- else
- ptk_boundingbox(ptrwindow->currentstid, &windowbox, TRUE);
- if (ptinlimit3(point, &windowbox))
- {
- windowfound = TRUE;
- *windowid = ptrwindow->windowid;
- *value = ptk_point(0.0, 0.0);
- }
- }
- }
- if (!windowfound)
- #ifndef HP
- /* do for SUN and PEXSI */
- i--;
- #endif
- #ifdef HP
- i++;
- #endif
- }
- if (windowfound)
- {
- if (ptrwindow->windowstate == PTKEWINDOWCLOSED)
- {
- *windowarea = PTKEWINDOWICON;
- ptk_boundingbox(ptrwindow->iconstid, &area, TRUE);
- }
- else
- {
- area = ptk_limit3(ptrwindow->windowposition.x -
- (ptrwindow->windowsize.x / 2.0),
- ptrwindow->windowposition.x +
- (ptrwindow->windowsize.x / 2.0),
- ptrwindow->windowposition.y -
- (ptrwindow->windowsize.y / 2.0),
- ptrwindow->windowposition.y +
- (ptrwindow->windowsize.y / 2.0), 0.0, 0.0);
- if (ptinlimit3(point, &area))
- *windowarea = PTKEWINDOWVIEW;
- else
- {
- area.y_min = area.y_max;
- area.y_max += ptrwindow->bannerheight;
- if (ptinlimit3(point, &area))
- *windowarea = PTKEWINDOWBANNER;
- else
- {
- *windowarea = PTKEWINDOWFRAME;
- /*#ifdef HP
- area = windowbox;
- #endif
- #ifdef SUN
- */
- ptk_openstruct(ptrwindow->currentstid);
- pset_elem_ptr(0);
- ptk_findelemtype(&eltype, 1, PDIR_FORWARD, &stat, &stopelem, &lstnum);
- ptk_closestruct();
- ptk_inittsl();
- ptk_tsltraverserange(ptrwindow->currentstid, 1,
- ptrwindow->currentstid, stopelem, TRUE);
- ptk_inqboundingbox(&area);
- /*
- #endif
- */
- }
- }
- }
- div = area.x_max - area.x_min;
- if (div != 0.0)
- value->x = (point->x - area.x_min)/div;
- div = area.y_max - area.y_min;
- if (div != 0.0)
- value->y = (point->y - area.y_min)/div;
- }
- ptk_delstore(store);
- free(structlist.postings);
- ptk_unstackbbox();
- ptk_unstacktsl();
- return windowfound;
- } /* ptk_locscanwindows */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern ptkboolean ptk_scanwindows(C(Pint) wsid, C(ptksgeneralinput *) input,
- C(ptkswindowoutput *) output)
- PreANSI(Pint wsid)
- PreANSI(ptksgeneralinput *input)
- PreANSI(ptkswindowoutput *output)
- /*
- ** \parambegin
- ** \param{Pint}{wsid}{workstation identifier}{IN}
- ** \param{ptksgeneralinput *}{input}{input data}{IN}
- ** \param{ptkswindowoutput *}{output}{output data}{IN}
- ** \paramend
- ** \blurb{This function performs a scan on all posted windows using
- ** either string, pick or locator data.
- ** The function returns TRUE if a window has been selected,
- ** otherwise FALSE.}
- */
- {
- ptkboolean result;
-
- switch (input->inputclass)
- {
-
- case PIN_LOC:
- result = ptk_locscanwindows(wsid, &input->ptkugeninput.locpoint, &output->windowid, &output->windowarea, &output->value);
- output->measure = TRUE;
- break;
-
- case PIN_STROKE:
- result = FALSE;
- break;
-
- case PIN_VAL:
- result = FALSE;
- break;
-
- case PIN_CHOICE:
- result = FALSE;
- break;
-
- case PIN_PICK:
- result = ptk_pickscanwindows(&input->ptkugeninput.ptkspickinput.pickdata,
- input->ptkugeninput.ptkspickinput.pathorder,
- &output->windowid, &output->windowarea);
- output->measure = FALSE;
- break;
-
- case PIN_STRING:
- result = ptk_stringscanwindows(wsid, input->ptkugeninput.str,
- &output->windowid);
- output->measure = FALSE;
- output->windowarea = PTKEWINDOWBANNER;
- break;
- }
- return result;
- } /* ptk_scanwindows */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqpostedwindows(C(Pint) wsid, C(Pint) size,
- C(Pint_list *) windowids, C(Pint *) totalsize,
- C(Pint *) err)
- PreANSI(Pint wsid)
- PreANSI(Pint size)
- PreANSI(Pint_list *windowids)
- PreANSI(Pint *totalsize)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{wsid}{workstation identifier}{IN}
- ** \param{Pint}{size}{size of buffer}{IN}
- ** \param{Pint\_list *}{windowids}{list of posted windows}{OUT}
- ** \param{Pint *}{totalsize}{length of posted windows list}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain a list of all windows
- ** posted to the workstation {\tt wsid}.
- ** The error code is a standard PHIGS error code.}
- */
- {
- ptkswindow *ptrwindow;
- Pint numstructs, i;
- Pposted_struct_list structlist;
-
- *err = 0;
- *totalsize = 0;
- ptrwindow = firstwind;
- while (ptrwindow != NULL)
- {
- if (ptrwindow->posted &&
- (ptrwindow->wsid == wsid))
- (*totalsize)++;
- ptrwindow = ptrwindow->next;
- }
- if (size >= *totalsize)
- {
- pinq_posted_structs(wsid, 0, 0, err, &structlist, &numstructs);
- structlist.postings = (Pposted_struct *)calloc(numstructs,
- sizeof(Pposted_struct));
- pinq_posted_structs(wsid, numstructs, 0, err, &structlist, &numstructs);
- windowids->num_ints = 0;
- for (i = 0; i < structlist.num_postings; i++)
- {
- if (iswindow(structlist.postings[i].id, &ptrwindow))
- {
- windowids->ints[windowids->num_ints] = ptrwindow->windowid;
- windowids->num_ints++;
- }
- }
- }
- } /* ptk_inqpostedwindows */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqwindowids(C(Pint) size, C(Pint_list *) windowids,
- C(Pint *) totalsize, C(Pint *) err)
- PreANSI(Pint size)
- PreANSI(Pint_list *windowids)
- PreANSI(Pint *totalsize)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{size}{size of buffer}{IN}
- ** \param{Pint\_list *}{windowids}{list of windows}{OUT}
- ** \param{Pint *}{totalsize}{length of windows list}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain a list of all
- ** windows in the PHIGS Toolkit window store.}
- */
- {
- ptkswindow *ptrwindow;
-
- *err = 0;
- *totalsize = windowcount;
- if (size >= *totalsize)
- {
- windowids->num_ints = 0;
- ptrwindow = firstwind;
- while (ptrwindow != NULL)
- {
- windowids->ints[windowids->num_ints] = ptrwindow->windowid;
- windowids->num_ints++;
- ptrwindow = ptrwindow->next;
- }
- }
- } /* ptk_inqwindowids */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqwindowstructid(C(Pint) windid, C(Pint *) windowstid,
- C(Pint *) iconstid, C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pint *windowstid)
- PreANSI(Pint *iconstid)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint *}{windowstid}{window structure identifier}{OUT}
- ** \param{Pint *}{iconstid}{window structure identifier}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the identifier of
- ** a window structure and its corresponding icon structure.
- ** The window structure is a network with references to all the items
- ** posted to the window. The default icon is a single structure
- ** containing the window identifier.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- {
- *windowstid = windptr->windowstid;
- *iconstid = windptr->iconstid;
- }
- else
- *err = 1;
- } /* ptk_inqwindowstructid */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqwindowname(C(Pint) windid, C(Pint *) name,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pint *name)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint *}{name}{window name}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the window name
- ** to be used in namesets for the pick, invisibility and
- ** highlighting filters.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *name = windptr->windowname;
- else
- *err = 1;
- } /* ptk_inqwindowname */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqwindowstate(C(Pint) windid, C(ptkewindowstate *) state,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(ptkewindowstate *state)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{ptkewindowstate *}{state}{window state, open or closed}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the window state,
- ** open or closed.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *state = windptr->windowstate;
- else
- *err = 1;
- } /* ptk_inqwindowstate */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern ptkboolean ptk_inqfrontbackwindowid(C(Pint) wsid, C(Pint *) frontid,
- C(ptkewindowstate *) frontstate, C(Pint *) backid,
- C(ptkewindowstate *) backstate, C(Pint *) err)
- PreANSI(Pint wsid)
- PreANSI(Pint *frontid)
- PreANSI(ptkewindowstate *frontstate)
- PreANSI(Pint *backid)
- PreANSI(ptkewindowstate *backstate)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{wsid}{workstation identifier}{IN}
- ** \param{Pint *}{frontstid}{front window identifier}{OUT}
- ** \param{ptkewindowstate *}{frontstate}{front window state}{OUT}
- ** \param{Pint *}{backstid}{back window identifier}{OUT}
- ** \param{ptkewindowstate *}{backstate}{back window state}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the identifiers
- ** of the front and back windows and there current state (OPEN or
- ** CLOSED).}
- */
- {
- Pint ind;
-
- *err = 0;
- findwsid(wsid, &ind);
- if (wswindows[ind].postedwindows)
- {
- *frontid = wswindows[ind].frontptr->windowid;
- *frontstate = wswindows[ind].frontptr->windowstate;
- *backid = wswindows[ind].backptr->windowid;
- *backstate = wswindows[ind].backptr->windowstate;
- return TRUE;
- }
- else
- return FALSE;
- } /* ptk_inqfrontbackwindowid */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqwindowposition(C(Pint) windid, C(Ppoint *) position,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Ppoint *position)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{position}{window position}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the position of the centre
- ** of a window. The position is returned in the range [0, 1].
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *position = windptr->windowposition;
- else
- *err = 1;
- } /* ptk_inqwindowposition */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqwindowsize(C(Pint) windid, C(Ppoint *) size,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Ppoint *size)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{size}{window size}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the size of a window
- ** which is returned in the range [0, 1].
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *size = windptr->windowsize;
- else
- *err = 1;
- } /* ptk_inqwindowsize */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqiconposition(C(Pint) windid, C(Ppoint *) position,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Ppoint *position)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{position}{icon position}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the position of the centre of
- ** a window icon which is returned in the range [0, 1].
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *position = windptr->iconposition;
- else
- *err = 1;
- } /* ptk_inqiconposition */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqiconsize(C(Pint) windid, C(Ppoint *) size, C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Ppoint *size)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{size}{icon size}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the size of a window's icon
- ** structure and is returned in the range [0, 1].
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *size = windptr->iconsize;
- else
- *err = 1;
- } /* ptk_inqiconsize */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqusericon(C(Pint) windid, C(Pint *) iconstid,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pint *iconstid)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint *}{iconstid}{user icon structure identifier}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the identifier of a
- ** user created icon structure. The structure is referenced by the
- ** window's icon structure.
- ** The error code = 1 if {\tt windid} doesn't exist and = 2 if
- ** the default icon is used.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- {
- if (!windptr->defaulticon)
- *iconstid = windptr->usericon;
- else
- *err = 2;
- }
- else
- *err = 1;
- } /* ptk_inqusericon */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqframesize(C(Pint) windid, C(Ppoint *) size,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Ppoint *size)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{size}{frame size}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the dimensions of the
- ** window frame. They are returned in the range [0, 1] and the default
- ** dimensions are (0.01, 0.01).
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *size = windptr->framesize;
- else
- *err = 1;
- } /* ptk_inqframesize */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqwindowtype(C(Pint) windid, C(ptkewindowtype *) type,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(ptkewindowtype *type)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{ptkewindowtype *}{type}{window type}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to inquire the type of a window.
- ** The available types are STRUCT, TOPOLOGY, CONTENT and TERMINAL.
- ** The default window type is STRUCT and may be used to view any PHIGS
- ** structures.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *type = windptr->windowtype;
- else
- *err = 1;
- } /* ptk_inqwindowtype */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqwindowattrs(C(Pint) windid,
- C(Pint *) titlefont, C(Pint *) titlecolour, C(Pint *) bannercolour,
- C(Pint *) backgdcolour, C(Pint *) edgecolour,
- C(Pint *) frametlcolour, C(Pint *) framebrcolour, C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pint *titlefont)
- PreANSI(Pint *titlecolour)
- PreANSI(Pint *bannercolour)
- PreANSI(Pint *backgdcolour)
- PreANSI(Pint *edgecolour)
- PreANSI(Pint *frametlcolour)
- PreANSI(Pint *framebrcolour)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint *}{titlefont}{title string font}{OUT}
- ** \param{Pint *}{titlecolour}{title string colour index}{OUT}
- ** \param{Pint *}{bannercolour}{banner colour index}{OUT}
- ** \param{Pint *}{backgdcolour}{background colour index of window}{OUT}
- ** \param{Pint *}{edgecolour}{edge colour index of window}{OUT}
- ** \param{Pint *}{frametlcolour}{top-left frame colour index}{OUT}
- ** \param{Pint *}{framebrcolour}{bottom-right frame colour index}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the text font and
- ** colour attribute values of a window.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- {
- *titlefont = windptr->titlefont;
- *titlecolour = windptr->titlecolour;
- *bannercolour = windptr->bannercolour;
- *backgdcolour = windptr->backgdcolour;
- *edgecolour = windptr->edgecolour;
- *frametlcolour = windptr->frametlcolour;
- *framebrcolour = windptr->framebrcolour;
- }
- else
- *err = 1;
- } /* ptk_inqwindowattrs */
-
- /*--------------------------------------------------------------------------*/
- /*-------------------------- icon functions --------------------------------*/
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_seticonposition(C(Pint) windid, C(Ppoint *) position)
- PreANSI(Pint windid)
- PreANSI(Ppoint *position)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{position}{icon position}{IN}
- ** \paramend
- ** \blurb{This function sets the position of the centre of the
- ** window's icon structure. The position is given in the range [0, 1].}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- if ((position->x > 0.0) && (position->x < 1.0) &&
- (position->y > 0.0) && (position->y < 1.0))
- {
- windptr->iconposition = *position;
- updateicon();
- }
- }
- } /* ptk_seticonposition */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_seticonsize(C(Pint) windid, C(Ppoint *) size)
- PreANSI(Pint windid)
- PreANSI(Ppoint *size)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Ppoint *}{size}{icon size}{IN}
- ** \paramend
- ** \blurb{This function sets the size of the window's icon structure.
- ** The size is given in the range [0, 1].}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- if ((size->x > 0.0) && (size->y > 0.0))
- {
- windptr->iconsize = *size;
- updateicon();
- }
- }
- } /* ptk_seticonsize */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setusericon(C(Pint) windid, C(Pint) usericon)
- PreANSI(Pint windid)
- PreANSI(Pint usericon)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint}{user icon}{icon structure identifier}{IN}
- ** \paramend
- ** \blurb{This function enables the application to specify a structure
- ** identifier to use as a window icon. The structure is executed from
- ** the window's default icon structure and the icon size and position
- ** functions still apply provided the user icon is defined within
- ** the World Coordinate range [0, 1].}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->defaulticon)
- {
- ptk_openstruct(windptr->iconstid);
- pset_elem_ptr(0);
- pdel_elems_labels(ptk_stringtoint("label", "begin-icon"),
- ptk_stringtoint("label", "end-icon"));
- ptk_seteditmode(PEDIT_INSERT);
- pexec_struct(usericon);
- ptk_unseteditmode();
- ptk_closestruct();
- windptr->defaulticon = FALSE;
- }
- }
- } /* ptk_setusericon */
-
- /*--------------------------------------------------------------------------*/
- /*------------------------- banner functions -------------------------------*/
-
- /*function:external*/
- extern void ptk_setbannercolours(C(Pint) windid, C(Pint) bannercolour,
- C(Pint) titlecolour)
- PreANSI(Pint windid)
- PreANSI(Pint bannercolour)
- PreANSI(Pint titlecolour)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint}{bannercolour}{banner colour index}{IN}
- ** \param{Pint}{titlecolour}{title string colour index}{IN}
- ** \paramend
- ** \blurb{This function sets the colour indicies of a window banner.
- ** It is useful for highlighting a current window, for example
- ** in a `point and click' window system.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- windptr->bannercolour = bannercolour;
- windptr->titlecolour = titlecolour;
- updateframe();
- }
- } /* ptk_setbannercolours */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setbannerheight(C(Pint) windid, C(Pfloat) bannerheight)
- PreANSI(Pint windid)
- PreANSI(Pfloat bannerheight)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pfloat}{bannerheight}{height of banner}{IN}
- ** \paramend
- ** \blurb{This function sets the height of the window banner to
- ** {\tt bannerheight} which is given in the range [0, 1]. The window
- ** title is re-scaled to fit the new height.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- windptr->bannerheight = bannerheight;
- updateframe();
- }
- } /* ptk_setbannerheight */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqbannerheight(C(Pint) windid, C(Pfloat *) bannerheight,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pfloat *bannerheight)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pfloat *}{bannerheight}{height of banner}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the height of a window
- ** banner. It is returned in the range [0, 1].
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- *bannerheight = windptr->bannerheight;
- else
- *err = 1;
- } /* ptk_inqbannerheight */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setbannertitle(C(Pint) windid, C(char *) titlestring)
- PreANSI(Pint windid)
- PreANSI(char *titlestring)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{char *}{titlestring}{title string of window banner}{IN}
- ** \paramend
- ** \blurb{This function sets the title string of a window. The title
- ** is displayed in the window banner and is automatically scaled to
- ** fit inside the banner area.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- strncpy(windptr->titlestring, titlestring, strlen(titlestring) + 1);
- updateframe();
- }
- } /* ptk_setbannertitle */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqbannertitle(C(Pint) windid, C(Pint) len,
- C(char *) titlestr, C(Pint *) totlen, C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pint len)
- PreANSI(char *titlestr)
- PreANSI(Pint *totlen)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint}{len}{length of string}{IN}
- ** \param{char *}{titlestr}{title string of banner}{IN}
- ** \param{Pint *}{totlen}{actual length of string}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the title of a window.
- ** The error code = 1 if {\tt windid} doesn't exist.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- {
- *totlen = strlen(windptr->titlestring) + 1;
- if (len >= *totlen)
- strncpy(titlestr, windptr->titlestring, *totlen);
- }
- else
- *err = 1;
- } /* ptk_inqbannertitle */
-
- /*--------------------------------------------------------------------------*/
- /*---------------------- Terminal window functions -------------------------*/
- /*--------------------------------------------------------------------------*/
-
- static void addline(C(char *) line, C(Pedit_mode) edtype)
- PreANSI(char *line)
- PreANSI(Pedit_mode edtype)
- /*
- ** \parambegin
- ** \param{}{termnum}{index to terminal window array}{IN}
- ** \param{}{line}{line to add or replace}{IN}
- ** \param{}{edtype}{edit mode}{IN}
- ** \paramend
- ** \blurb{Updates the PHIGS structure containing the terminal window
- ** text. Either replaces the last line or inserts a new one.}
- */
- {
- Ppoint textpos;
- Pint i;
-
- /* initialise ptr to last elem */
- /* remove old text elements from structure */
- ptk_openstruct(windptr->term.textstid);
- poffset_elem_ptr(-1);
- ptk_seteditmode(edtype);
-
- /* insert new text element */
- i = windptr->term.curr_line;
- textpos = ptk_point(ptkctmlinespace,
- -(Pfloat)i * windptr->term.increment);
- ptext(&textpos, line);
- ptk_unseteditmode();
- ptk_closestruct();
- } /* addline */
-
- /*--------------------------------------------------------------------------*/
-
- static void setterminalline()
- {
- Pfloat oneline;
-
- /* view orientation */
- oneline = -windptr->windowsize.y/(Pfloat)windptr->term.lines;
- windptr->vrp = ptk_point3(0.0, -windptr->windowsize.y +
- (oneline * (Pfloat)(windptr->term.visline - 1)), 0.0);
- /* set view rep */
- updateview();
- } /* setterminalline */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_scrollterminal(C(Pint) windid, C(Ptext_path) scrolldir,
- C(Pint) numlines)
- PreANSI(Pint windid)
- PreANSI(Ptext_path scrolldir)
- PreANSI(Pint numlines)
- /*
- ** \parambegin
- ** \param{}{windid}{terminal window identifier}{IN}
- ** \param{}{scrolldir}{scroll direction (up or down)}{IN}
- ** \param{}{numlines}{number of lines to scroll by}{IN}
- ** \paramend
- ** \blurb{This function scrolls the contents of the TERMINAL window
- ** either UP or DOWN by {\tt numlines}.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETERMINALWINDOW)
- {
- switch (scrolldir)
- {
- case PPATH_DOWN:
- windptr->term.visline -= numlines;
- break;
-
- case PPATH_UP:
- windptr->term.visline += numlines;
- break;
-
- case PPATH_LEFT:
- break;
-
- case PPATH_RIGHT:
- break;
- }
- setterminalline();
- }
- }
- } /* ptk_scrollterminal */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setterminaldata(C(Pint) windid, C(Pint) numlines,
- C(Pint) txfont, C(Pint) txcolour)
- PreANSI(Pint windid)
- PreANSI(Pint numlines)
- PreANSI(Pint txfont)
- PreANSI(Pint txcolour)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \param{Pint}{numlines}{number of lines in window}{IN}
- ** \param{Pint}{numcolmns}{number of columns in window}{IN}
- ** \param{Pint}{txfont}{text font}{IN}
- ** \param{Pint}{txcolour}{text colour}{IN}
- ** \paramend
- ** \blurb{This function sets the number of lines to be displayed in a
- ** TERMINAL window and which text font and colour to use.}
- */
- {
- char stname[30];
- Pint termnum, err, wstype;
- Pfloat linespace, chrht, textheight, textwidth;
- Ptext_align align;
- void *connid;
- Prect rect;
- Ppoint offset;
- Pfloat wwidth, wheight, charheight, charwidth, lineheight;
- Pstore store;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETERMINALWINDOW)
- {
- windptr->term.lines = numlines;
-
- /* create structure with appropriate attr */
- pempty_struct(windptr->term.textstid);
- ptk_openstruct(windptr->term.textstid);
-
- /* user specified font*/
- windptr->term.txfont = txfont;
- windptr->term.txcolour = txcolour;
- pset_text_font(txfont);
- pset_text_colr_ind(txcolour);
- align.hor = PHOR_NORM;
- align.vert = PVERT_BOTTOM;
- pset_text_align(&align);
- /* size characters so they all fit within window */
- textwidth = windptr->windowsize.x * 0.99;
- textheight = windptr->windowsize.y * 0.9;
- linespace = (windptr->windowsize.y * 0.1)/(Pfloat)windptr->term.lines;
-
- /* character height */
- /* Implementation dependent bit because HP and PEXSI doesn't support
- ** INQUIRE TEXT EXTENT. For HP and PEXSI assume font 1.
- */
- #ifdef SUN
- pcreate_store(&err, &store);
- pinq_ws_conn_type(windptr->wsid, store, &err, &connid, &wstype);
- pinq_text_extent(wstype, txfont, 1.0, 0.0, 0.01, PPATH_RIGHT,
- PHOR_NORM, PVERT_NORM, "W", &err, &rect, &offset);
- #endif
- #ifdef HP
- rect.p = ptk_point(0.0, 0.0);
- rect.q = ptk_point(0.01, 0.015);
- #endif
- #ifdef PEXSI
- rect.p = ptk_point(0.0, 0.0);
- rect.q = ptk_point(0.01, 0.015);
- #endif
-
- wheight = rect.q.y - rect.p.y;
- wwidth = rect.q.x - rect.p.x;
-
- lineheight = textheight / (Pfloat)numlines;
- charheight = 0.01 * (lineheight / wheight);
- charwidth = wwidth * (lineheight / wheight);
- pset_char_ht(charheight);
- windptr->term.increment = textheight/(Pfloat)windptr->term.lines
- + linespace;
- windptr->term.realcols = textwidth / charwidth;
- windptr->term.columns = (Pint)windptr->term.realcols;
- windptr->term.reallines = (Pfloat)numlines;
- plabel(ptk_stringtoint("label", "$tm_starttext"));
- /* put text elements here */
- plabel(ptk_stringtoint("label", "$tm_endtext"));
- ptk_closestruct();
- ptk_delstore(store);
- }
- }
- } /* ptk_setterminaldata */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqterminaldata(C(Pint) windid, C(Pint *) numlines,
- C(Pint *) numcolms, C(Pint *) txfont, C(Pint *) txcolour,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pint *numlines)
- PreANSI(Pint *numcolms)
- PreANSI(Pint *txfont)
- PreANSI(Pint *txcolour)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \param{Pint *}{numlines}{number of lines in window}{OUT}
- ** \param{Pint *}{numcolmns}{number of columns in window}{OUT}
- ** \param{Pint *}{txfont}{text font}{OUT}
- ** \param{Pint *}{txcolour}{text colour}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the number of lines
- ** displayed in a TERMINAL window and the number of characters in a line.
- ** Also the text font and colour used are returned in {\tt txfont} and
- ** {\tt txcolour}. The error code = 1 if {\tt windid} doesn't exist
- ** and = 2 if it is not a terminal window.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETERMINALWINDOW)
- {
- *numlines = windptr->term.lines;
- *numcolms = windptr->term.columns;
- *txfont = windptr->term.txfont;
- *txcolour = windptr->term.txcolour;
- }
- else
- *err = 2;
- }
- else
- *err = 1;
- } /* ptk_inqterminaldata */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_refreshterminal(C(Pint) windid)
- PreANSI(Pint windid)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \paramend
- ** \blurb{This function refreshes the TERMINAL window so that the
- ** last text line is visible.}
- */
- {
- Pint linediff;
-
- /* show updates */
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETERMINALWINDOW)
- {
- linediff = windptr->term.curr_line - windptr->term.visline;
- if (abs(linediff) >= windptr->term.lines)
- {
- windptr->term.visline = windptr->term.curr_line -
- windptr->term.lines + 1;
- setterminalline();
- }
- }
- }
- } /* ptk_refreshterminal */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_writeterminal(C(Pint) windid, C(char *) str)
- PreANSI(Pint windid)
- PreANSI(char *str)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \param{char *}{str}{string to write to window}{IN}
- ** \paramend
- ** \blurb{This function writes a character string to the current line
- ** of the TERMINAL window. A new line is started when the end of the
- ** current line is reached.}
- */
- {
- Pint wtlen, spaceleft, stringleft, allocsize;
- Pint cpylen;
- char *templine;
- Pint termnum;
- Pedit_mode emode;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETERMINALWINDOW)
- {
- templine = windptr->term.lastline;
-
- /* length of string to write */
- wtlen = strlen(str);
-
- /* number of character spaces left on current line */
- spaceleft = windptr->term.columns - windptr->term.curr_colm;
-
- /* add into current line if possible */
-
- if (spaceleft > 0)
- {
- /* allocate space for line */
- if (wtlen > spaceleft)
- /* spans more than one line */
- allocsize = windptr->term.columns + 1;
- else
- /* fits entirely on current line */
- allocsize = windptr->term.curr_colm + wtlen + 1;
- if (templine == NULL)
- {
- templine = (char *)malloc(allocsize);
- emode = PEDIT_INSERT;
- }
- else
- {
- templine = (char *)realloc(windptr->term.lastline, allocsize);
- emode = PEDIT_REPLACE;
- }
-
- /* cpylen = min(wtlen, spaceleft) */
- cpylen = wtlen < spaceleft ? wtlen : spaceleft;
-
- /* copy as much of str as possible into current line */
- strncpy(&templine[windptr->term.curr_colm],
- str, cpylen);
-
- windptr->term.curr_colm = allocsize - 1;
- templine[allocsize - 1] = '\0';
- addline(templine, emode);
- }
-
- stringleft = wtlen - spaceleft;
-
- while (stringleft > 0)
- {
- /* create a new line */
- /* allocate space for line */
-
- if (stringleft > windptr->term.columns)
- allocsize = windptr->term.columns + 1;
- else
- allocsize = stringleft + 1;
- free(templine);
- templine = NULL;
- templine = (char *)malloc(sizeof(char) * allocsize);
-
- /* copy as much of string as possible */
- strncpy(templine, &str[wtlen - stringleft],
- allocsize);
- windptr->term.curr_line++;
- windptr->term.curr_colm = allocsize - 1;
- templine[allocsize - 1] = '\0';
- stringleft -= windptr->term.columns;
- addline(templine, PEDIT_INSERT);
-
- } /* while */
-
- windptr->term.lastline = templine;
-
- ptk_refreshterminal(windid);
- }
- }
- } /* ptk_writeterminal */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_writelnterminal(C(Pint) windid, C(char *) str)
- PreANSI(Pint windid)
- PreANSI(char *str)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \param{char *}{str}{string to write to window}{IN}
- ** \paramend
- ** \blurb{This function writes a character string to the current line
- ** of the TERMINAL window. A new line is started when the end of the current
- ** line is reached and at the next call to a TERMINAL write function.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETERMINALWINDOW)
- {
- ptk_writeterminal(windid, str);
- /* goto end of line */
- windptr->term.curr_colm = windptr->term.columns;
- }
- }
- } /* ptk_writelnterminal */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_printfterminal(C(Pint) windid, C(char *) format, va_alist)
- PreANSI(Pint windid)
- PreANSI(char *format)
- va_dcl
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \param{char *}{format}{format string}{IN}
- ** \param{}{va\_alist}{variable length argument list}{IN}
- ** \paramend
- ** \blurb{This function writes to a TERMINAL window using a variable length
- ** argument list and a format string like the C printf function.}
- */
- {
- va_list args;
- char str[255], line[255];
- char *newline, *firstchar;
-
- va_start(args);
- vsprintf(str, format, args);
- va_end(args);
-
- firstchar = &str[0];
- while ((newline = strchr(firstchar, '\n')) != NULL)
- {
- strncpy(line, firstchar, (newline - firstchar));
- line[newline - firstchar] = '\0';
- ptk_writelnterminal(windid, line);
- firstchar = newline + 1;
- }
-
- if (firstchar != '\0')
- ptk_writeterminal(windid, firstchar);
- } /* ptk_printfterminal */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_clearterminal(C(Pint) windid)
- PreANSI(Pint windid)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \paramend
- ** \blurb{This function empties the structure containing all the text
- ** written to the TERMINAL window.}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETERMINALWINDOW)
- {
- /* first clear out PHIGS structure */
- ptk_openstruct(windptr->term.textstid);
- pset_elem_ptr(0);
- pdel_elems_labels(ptk_stringtoint("label", "$tm_starttext"),
- ptk_stringtoint("label", "$tm_endtext"));
- ptk_closestruct();
- predraw_all_structs(windptr->wsid, PFLAG_ALWAYS);
-
- /* now clear out data structure */
- windptr->term.curr_line = 0;
- windptr->term.curr_colm = windptr->term.columns;
- windptr->term.visline = 0;
-
- free(windptr->term.lastline);
- windptr->term.lastline = NULL;
- ptk_scrollterminal(windid, PPATH_UP, 1);
- }
- }
- } /* ptk_clearterminal */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_writeintterminal(C(Pint) windid, C(Pint) number)
- PreANSI(Pint windid)
- PreANSI(Pint number)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \param{Pint}{number}{integer to write to window}{IN}
- ** \paramend
- ** \blurb{This function writes an integer to a TERMINAL window.}
- */
- {
- char intstr[81];
-
- sprintf(intstr, "%d", number);
- ptk_writeterminal(windid, intstr);
- } /* ptk_writeintterminal */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_writefloatterminal(C(Pint) windid, C(Pfloat) number)
- PreANSI(Pint windid)
- PreANSI(Pfloat number)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \param{Pfloat}{number}{float number to write to window}{IN}
- ** \paramend
- ** \blurb{This function writes a floating point number to a TERMINAL window.}
- */
- {
- char floatstr[81];
-
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETERMINALWINDOW)
- {
- sprintf(floatstr, windptr->term.floatformat, number);
- ptk_writeterminal(windid, floatstr);
- }
- }
- } /* ptk_writefloatterminal */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setterminalfloatformat(C(Pint) windid, C(char *) rformat)
- PreANSI(Pint windid)
- PreANSI(char *rformat)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \param{char *}{rformat}{string giving C-type float number output style}{IN}
- ** \paramend
- ** \blurb{This function sets the format for writing floating-point numbers
- ** to a TERMINAL window. The format used is the same syntax as in the
- ** C language.}
- */
- {
- Pint rlen;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETERMINALWINDOW)
- {
- rlen = strlen(rformat);
- if (rlen > ptkcfloatformat)
- rlen = ptkcfloatformat;
- strncpy(windptr->term.floatformat, rformat, (rlen + 1));
- }
- }
- } /* ptk_setterminalfloatformat */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqterminalfloatformat(C(Pint) windid, C(Pint) size,
- C(Pint *) totalsize, C(char *) rformat, C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pint size)
- PreANSI(Pint *totalsize)
- PreANSI(char *rformat)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \param{Pint}{size}{size of buffer, in bytes, as allocated by application}{IN}
- ** \param{Pint *}{totalsize}{actual size of buffer}{IN}
- ** \param{char *}{rformat}{string giving C-type float number output style}{IN}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the floating-point used
- ** for writing floating-point numbers to a TERMINAL window.
- ** The error code = 1 if {\tt windid} doesn't exist and = 2 if it is
- ** not a terminal window.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETERMINALWINDOW)
- {
- *totalsize = strlen(windptr->term.floatformat) + 1;
- if (size >= *totalsize)
- {
- strncpy(rformat, windptr->term.floatformat, *totalsize);
- rformat[*totalsize - 1] = '\0';
- }
- }
- else
- *err = 2;
- }
- else
- *err = 1;
- } /* ptk_inqterminalfloatformat */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqterminalstructid(C(Pint) windid, C(Pint *) termtextstid,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pint *termtextstid)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \param{Pint *}{rformat}{string giving C-type real number output style}{IN}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the identifier of the
- ** structure used to display the text written to a TERMINAL window.
- ** The error code = 1 if {\tt windid} doesn't exist and = 2 if it is
- ** not a terminal window.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETERMINALWINDOW)
- *termtextstid = windptr->term.textstid;
- else
- *err = 2;
- }
- else
- *err = 1;
- } /* ptk_inqterminalstructid */
-
- /*--------------------------------------------------------------------------*/
- /*----------------------- Topology window functions ------------------------*/
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_settopologyviewarea(C(Pint) windid, C(Plimit *) viewarea)
- PreANSI(Pint windid)
- PreANSI(Plimit *viewarea)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Plimit *}{viewarea}{area of topology to view}{IN}
- ** \paramend
- ** \blurb{This function sets the viewing area of a topology diagram posted
- ** to a TOPOLOGY window. The area is defined in the range [0, 1].}
- */
- {
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETOPOLOGYWINDOW)
- {
- /* calculate aspect ratio of window */
- windptr->topviewarea = windptr->win = *viewarea;
- windptr->proj_ref_point.x = windptr->win.x_min +
- (windptr->win.x_max - windptr->win.x_min) / 2.0;
- windptr->proj_ref_point.y = windptr->win.y_min +
- (windptr->win.y_max - windptr->win.y_min) / 2.0;
- updateview();
- }
- }
- } /* ptk_settopologyviewarea */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqtopologyviewarea(C(Pint) windid, C(Plimit *) viewarea,
- C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Plimit *viewarea)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Plimit *}{viewarea}{area of topology to view}{OUT}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the viewing area
- ** of a topology diagram posted to a TOPOLOGY window.
- ** The error code = 1 if {\tt windid} doesn't exist and = 2 if it is
- ** not a topology window.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKETOPOLOGYWINDOW)
- *viewarea = windptr->topviewarea;
- else
- *err = 2;
- }
- else
- *err = 1;
- } /* ptk_inqtopologyviewarea */
-
- /*--------------------------------------------------------------------------*/
- /*----------------------- Content window functions -------------------------*/
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setcontentviewrange(C(Pint) windid, C(Pint) range1,
- C(Pint) range2)
- PreANSI(Pint windid)
- PreANSI(Pint range1)
- PreANSI(Pint range2)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{Pint}{range1}{start element number}{IN}
- ** \param{Pint}{range2}{end element number}{IN}
- ** \paramend
- ** \blurb{This function sets the range of elements of a structure
- ** content diagram to view in a CONTENT window.}
- */
- {
- Pfloat projht, projwt, winht, winwt, aspectratio, winaspectratio;
- Pfloat diff, elemspace, fudge;
- Pint numelems, first, last, viewelems;
-
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKECONTENTWINDOW)
- {
- /* check range is valid */
- first = range1;
- last = range2;
- if (range1 < 0)
- first = windptr->range1;
- if ((range2 > windptr->range2) || (range2 == 0))
- last = windptr->range2;
- if (last < first)
- last = first;
-
- windptr->viewrange1 = first;
- windptr->viewrange2 = last;
- /* calculate window given element range to view */
- numelems = windptr->range2 - windptr->range1 + 2;
-
- if (numelems < 10)
- elemspace = 0.1;
- else
- elemspace = 1.0 / (Pfloat)numelems;
- fudge = 0.01/(Pfloat)numelems;
- windptr->win.y_max = 1.0 - ((Pfloat)(first - windptr->range1 + 1) *
- elemspace);
- windptr->win.y_min = 1.0 - ((Pfloat)(last - windptr->range1 + 2) *
- elemspace) - fudge;
- windptr->win.x_min = 0.0;
- viewelems = last - first + 1;
- if (viewelems < 10)
- viewelems = 10;
- if (numelems < 10)
- windptr->win.x_max = 1.0;
- else
- windptr->win.x_max = (Pfloat)viewelems / (Pfloat)numelems;
- /* calculate aspect ratio of window */
- projht = windptr->win.y_max - windptr->win.y_min;
- projwt = windptr->win.x_max - windptr->win.x_min;
- aspectratio = projht / projwt;
-
- /* adjust view area to have same aspect ratio as window */
- windptr->viewbox = windptr->proj_vp = windptr->viewlims;
- winht = windptr->proj_vp.y_max - windptr->proj_vp.y_min;
- winwt = windptr->proj_vp.x_max - windptr->proj_vp.x_min;
- winaspectratio = winht / winwt;
-
- if (aspectratio > winaspectratio)
- {
- /* decrease x */
- diff = (winwt - ((1.0 / aspectratio) * winht));
- windptr->proj_vp.x_max -= diff;
- }
- else
- if (aspectratio < winaspectratio)
- {
- /* decrease y */
- diff = (winht - (aspectratio * winwt));
- windptr->proj_vp.y_min += diff;
- }
-
- windptr->proj_ref_point = ptk_point3(
- (windptr->win.x_max - windptr->win.x_min) / 2.0,
- (windptr->win.y_min +
- (windptr->win.y_max - windptr->win.y_min) / 2.0), 2.0);
-
- updateview();
- }
- }
- } /* ptk_setcontentviewrange */
-
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_inqcontentviewrange(C(Pint) windid, C(Pint *) range1,
- C(Pint *) range2, C(Pint *) err)
- PreANSI(Pint windid)
- PreANSI(Pint *range1)
- PreANSI(Pint *range2)
- PreANSI(Pint *err)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{terminal window identifier}{IN}
- ** \param{Pint}{range1}{element number}{IN}
- ** \param{Pint}{range2}{element number}{IN}
- ** \param{Pint *}{err}{error indicator}{OUT}
- ** \paramend
- ** \blurb{This function may be used to obtain the viewing range of
- ** a structure content diagram which is posted to a CONTENT window.
- ** The error code = 1 if {\tt windid} doesn't exist and = 2 if it is
- ** not a content window.}
- */
- {
- *err = 0;
- setwindow(windid);
- if (windptr != NULL)
- {
- if (windptr->windowtype == PTKECONTENTWINDOW)
- {
- *range1 = windptr->viewrange1;
- *range2 = windptr->viewrange2;
- }
- else
- *err = 2;
- }
- else
- *err = 1;
- } /* ptk_inqcontentviewrange */
-
- /*--------------------------------------------------------------------------*/
- /*----------------------- Window type functions ----------------------------*/
- /*--------------------------------------------------------------------------*/
-
- /*function:external*/
- extern void ptk_setwindowtype(C(Pint) windid, C(ptkewindowtype) windtype)
- PreANSI(Pint windid)
- PreANSI(ptkewindowtype windtype)
- /*
- ** \parambegin
- ** \param{Pint}{windid}{window identifier}{IN}
- ** \param{ptkewindowtype}{windtype}{window type}{IN}
- ** \paramend
- ** \blurb{This function sets the type of a window to one of
- ** STRUCT, TOPOLOGY, CONTENT and TERMINAL. The default window type is
- ** STRUCT. All items are unposted from the window before the type
- ** is set.}
- */
- {
- char stname[20];
-
- setwindow(windid);
- if (windptr != NULL)
- {
- windptr->windowtype = windtype;
- ptk_unpostallfromwindow(windid);
- switch (windtype)
- {
- case PTKESTRUCTWINDOW:
- /* change icon */
- ptk_openstruct(windptr->iconstid);
- pset_elem_ptr(0);
- pdel_elems_labels(ptk_stringtoint("label", "begin-icon-pic"),
- ptk_stringtoint("label", "end-icon"));
- ptk_seteditmode(PEDIT_INSERT);
- do_structicon();
- ptk_unseteditmode();
- ptk_closestruct();
- break;
-
- case PTKETERMINALWINDOW:
- /* create a text structure */
- sprintf(stname, "ptk$term%d", windid);
- windptr->term.textstid = ptk_stringtoint("structureid", stname);
-
- /* post to window */
- ptk_openstruct(windptr->windowstid);
- ptk_seteditmode(PEDIT_INSERT);
- pset_elem_ptr(0);
- pset_elem_ptr_label(ptk_stringtoint("label", "begin-window"));
- pexec_struct(windptr->term.textstid);
- ptk_unseteditmode();
- ptk_closestruct();
-
- /* initialise */
- windptr->term.curr_line = 0;
- windptr->term.visline = 0;
- strncpy(windptr->term.floatformat, "%.5e", 5);
- windptr->term.lastline = NULL;
- ptk_setterminaldata(windid, 20, 1, 1);
- windptr->term.curr_colm = windptr->term.columns;
- /* initialise view */
- windptr->cameraswitch = PTKECAMERAOFF;
- initialiseterminal();
- ptk_scrollterminal(windid, PPATH_UP, 1);
-
- /* change icon */
- ptk_openstruct(windptr->iconstid);
- pset_elem_ptr(0);
- pdel_elems_labels(ptk_stringtoint("label", "begin-icon-pic"),
- ptk_stringtoint("label", "end-icon"));
- ptk_seteditmode(PEDIT_INSERT);
- do_terminalicon();
- ptk_unseteditmode();
- ptk_closestruct();
- break;
-
- case PTKETOPOLOGYWINDOW:
- windptr->proj_vp = ptk_limit3(0.0, 1.0, 0.0, 1.0, 0.0, 1.0);
- /* default viewing variables */
- windptr->proj_type = PTYPE_PARAL;
- windptr->vrp = ptk_point3(0.0, 0.0, 0.0);
- windptr->proj_ref_point = ptk_point3(0.5, 0.5, 2.0);
- windptr->vpn = ptk_point3(0.0, 0.0, 1.0);
- windptr->vup = ptk_point3(0.0, 1.0, 0.0);
- windptr->topviewarea = windptr->win = ptk_limit(0.0, 1.0, 0.0, 1.0);
- windptr->viewplane = windptr->frontplane = 1.0;
- windptr->backplane = 0.0;
-
- /* other window defaults */
- windptr->cameraswitch = PTKECAMERAOFF;
- updateview();
-
- /* change icon */
- ptk_openstruct(windptr->iconstid);
- pset_elem_ptr(0);
- pdel_elems_labels(ptk_stringtoint("label", "begin-icon-pic"),
- ptk_stringtoint("label", "end-icon"));
- ptk_seteditmode(PEDIT_INSERT);
- do_topologyicon();
- ptk_unseteditmode();
- ptk_closestruct();
- break;
-
- case PTKECONTENTWINDOW:
- windptr->cliplimit = windptr->viewlims;
- /* default viewing variables */
- windptr->proj_type = PTYPE_PARAL;
- windptr->vrp = ptk_point3(0.0, 0.0, 0.0);
- windptr->proj_ref_point = ptk_point3(0.5, 0.5, 2.0);
- windptr->vpn = ptk_point3(0.0, 0.0, 1.0);
- windptr->vup = ptk_point3(0.0, 1.0, 0.0);
- windptr->win = ptk_limit(0.0, 1.0, 0.0, 1.0);
- windptr->viewplane = windptr->frontplane = 1.0;
- windptr->backplane = 0.0;
-
- /* other window defaults */
- windptr->cameraswitch = PTKECAMERAOFF;
- updateview();
-
- /* change icon */
- ptk_openstruct(windptr->iconstid);
- pset_elem_ptr(0);
- pdel_elems_labels(ptk_stringtoint("label", "begin-icon-pic"),
- ptk_stringtoint("label", "end-icon"));
- ptk_seteditmode(PEDIT_INSERT);
- do_contenticon();
- ptk_unseteditmode();
- ptk_closestruct();
- break;
- }
- }
- } /* ptk_setwindowtype */
-
- /*--------------------------------------------------------------------------*/
-
- /* end of wind.c */
-
-